다음을 통해 공유


SpellCheck.CustomDictionaries 속성

정의

사용자 지정 맞춤법 검사에 사용되는 어휘 파일 위치의 컬렉션을 가져옵니다.

public:
 property System::Collections::IList ^ CustomDictionaries { System::Collections::IList ^ get(); };
public System.Collections.IList CustomDictionaries { get; }
member this.CustomDictionaries : System.Collections.IList
Public ReadOnly Property CustomDictionaries As IList

속성 값

어휘집 파일 위치의 컬렉션입니다.

예제

다음 예제에서는 두 개의 사용자 지정 사전을 RichTextBox추가하는 방법을 보여 있습니다. 첫 번째 사용자 지정 사전(customwords.lex)이 XAML에 추가됩니다. 파일은 애플리케이션에 콘텐츠 파일로 포함되고 출력 디렉터리에 복사됩니다. 요소를 사용 Uri 하려면 시스템 네임스페이스를 포함해야 합니다.

xmlns:sys="clr-namespace:System;assembly=System"

두 번째 사용자 지정 사전(customwords2.lex)이 이벤트 처리기에 추가 Click 됩니다. 파일은 리소스 파일로 포함되고 WPFCustomDictionary라는 애플리케이션 어셈블리로 컴파일됩니다.

<RichTextBox Margin="38,18,40,0" Name="richTextBox1" Height="45" VerticalAlignment="Top" SpellCheck.IsEnabled="True" >
    <SpellCheck.CustomDictionaries>
        <!-- customwords.lex is included as a content file-->
        <sys:Uri>pack://application:,,,/customwords.lex</sys:Uri>
    </SpellCheck.CustomDictionaries>
</RichTextBox>
private void button1_Click(object sender, RoutedEventArgs e)
{
    IList dictionaries = SpellCheck.GetCustomDictionaries(richTextBox1);
    // customwords2.lex is included as a resource file
    dictionaries.Add(new Uri(@"pack://application:,,,/WPFCustomDictionary;component/customwords2.lex"));
}
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    Dim dictionaries As IList = SpellCheck.GetCustomDictionaries(richTextBox1)
    ' customwords2.lex is included as a resource file
    dictionaries.Add(New Uri("pack://application:,,,/WPFCustomDictionary;component/customwords2.lex"))
End Sub

설명

사용자 지정 사전은 .lex 확장명이 있는 텍스트 파일인 어휘집 파일을 사용합니다. 어휘집 파일의 각 줄에는 합법적인 맞춤법으로 허용되는 단일 단어가 포함되어 있습니다. 파일의 첫 번째 줄은 사전이 적용되는 LCID(로캘 식별자)를 지정할 수 있습니다. 로캘을 지정하지 않으면 사전이 모든 언어에 적용됩니다. 자세한 내용은 로캘 ID를 참조하세요. 다음 예제에서는 영어에 대한 어휘집 파일의 처음 몇 줄을 보여 냅니다.

#LID 1033
TextBlock
TextBox
ListBox

파생되는 TextBoxBase클래스에 대해 TextBox 하나 이상의 사용자 지정 사전을 지정하려면 컬렉션에 파일의 URI를 추가하여 어휘집 파일 CustomDictionaries 의 위치를 지정합니다.

메모

컬렉션에 파일을 추가하는 데 CustomDictionaries 사용하면 Insert 예외가 발생합니다. 대신 컬렉션을 사용하고 AddRemove 업데이트합니다.

어휘집 파일은 로컬 컴퓨터에 설치된 콘텐츠 파일 또는 로컬 참조 어셈블리로 컴파일된 리소스 파일로 애플리케이션에 포함될 수 있습니다. 팩 URI를 사용하여 파일을 참조할 수 있습니다. 자세한 내용은 WPF의 Pack URI를 참조하세요.

맞춤법 검사기를 사용하도록 설정하려면 속성 trueSpellCheck.IsEnabled 파생되는 클래스에 TextBox 대해 또는 에서 파생TextBoxBase되는 클래스로 설정합니다. 기본 맞춤법 검사기 외에 TextBox 모든 사용자 지정 사전이 사용됩니다. 맞춤법 검사에 대한 자세한 내용은 다음을 참조하세요 SpellCheck.

적용 대상

추가 정보