Monday, March 28, 2011

Setting Culture / Language in RichTextBox WPF

Hi there is possible to set a default language or set a new one in RichTextBox, i want to set it in "es-PE" for spellchecker propouses

Thanks!

From stackoverflow
  • Have you tried setting the current thread's culture to the one you want? Most stuff in .NET takes the culture from the thread.

    Thread.CurrentThread.CurrentCulture = new Culture( "es-PE" );
    Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
    
    John : This would effect all of the RichTextBox controls in the application
    Angel Escobedo : cant find Culture Namespace
  • ...RichTextBox Language="es-PE" Name="mainRTB" AcceptsTab="True" SpellCheck.IsEnabled="True"...

    sorry i was thinking extending the control and using System.Windows.Forms.InputLanguage ...(fx 2.0)

  • It would seem to be possible setting the xml:lang as in the code below:

       <StackPanel>
        <RichTextBox SpellCheck.IsEnabled="True"/>
        <RichTextBox SpellCheck.IsEnabled="True" xml:lang="es-PE"/>
    </StackPanel>
    

    The first box checks in the default culture and the second in the specified one ("es-PE").

    The documentation also suggests you could add this attribute to a parent control such as a panel and it will be inherited by the child controls.

0 comments:

Post a Comment