Tuesday 12 March 2019

Wpf custom dictionary. Notes

Wpf uses #LID to indicate the language or dialect of the dictionary which it will pick up from the current localization.

e.g.
#LID 2057 = UK location

Must include

  1. the System namespace in xaml,
  2. SpellCheck.IsEnabled="True" in the control,
  3. location of the dictionary.

Best set build action of the dictionary to embedded resource.

<Window ...
  xmlns:sys="clr-namespace:System;assembly=System">
  <!-- Must include System namespace in xaml -->

  <TextBox SpellCheck.IsEnabled="True">
    <SpellCheck.CustomDictionaries>
      <!-- List of dictionaries to use -->
      <!-- hard-coded -->
      <sys:Uri>c:\pathToDictionary\uk.lex</sys:Uri>
      <!-- OR: Embedded resource -->
      <sys:Uri>pack://application:,,,/MyWpfProject;component/uk.lex</sys:Uri>
      <!-- Must set uk.lex  Build Action = Embedded Resource -->
    </SpellCheck.CustomDictionaries>
  </TextBox>

MyWpfProject - being the name of the application, in this example.

No comments:

Post a Comment