I need to turn spellcheck on for a richtextbox, and set the language to one the user has picked from a drop down. For now, I'm just testing it by building the richtextbox in xaml and providing a language to the xaml language attribute.
I've read two different resources and one says I need to set the language attribute, and the other says I need to set the xml:lang attribute. Neither seems to work. I've tried setting either one to "es" for Spanish, and I've also tried setting both to "es". I've also tried french by setting them to "fr-FR", without success. The only thing that happens is that english words aren't marked, but the other language words are marked as misspelled.
I also read that I need to change the keyboard language. This would be a problem for my application as the language within the application needs to be switched on the fly, so having the end user go to their keyboard settings just so spellcheck will work is a problem. However, I've changed my keyboard settings, and spell check still does not work properly. This time it doesn't mark anything as misspelled, even misspelled english words.
What am I missing?
Edit: some links to my references above http://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck(v=VS.100).aspx
http://www.dev102.com/2008/03/25/customize-spellcheck-on-wpf-text-controls/
http://books.google.com/books?id=clLc5BBHqRMC&pg=PA121&lpg=PA121&dq=C%23+wpf+enable+spellcheck&source=bl&ots=_r59pZRDjP&sig=yHMBc39EHKK5gaRMzxlBaEsY890&hl=en&ei=oXnIS8zWH4G88gaq48yGBw&sa=X&oi=book_result&ct=result&resnum=6&ved=0CBMQ6AEwBQ#v=onepage&q&f=false
I'm not sure where the problem lays for you, but this definitely works on my machine:
<StackPanel>
<TextBox SpellCheck.IsEnabled="True"
Language="{Binding SelectedItem.Content, ElementName=lg, ConverterCulture=en-us}">
Turtle tortue tortuga Schildkröte
</TextBox>
<ComboBox Name="lg">
<ComboBoxItem Selector.IsSelected="True">en-US</ComboBoxItem>
<ComboBoxItem>fr-FR</ComboBoxItem>
<ComboBoxItem>es-ES</ComboBoxItem>
<ComboBoxItem>de-DE</ComboBoxItem>
</ComboBox>
</StackPanel>
Edit works in 3.5, not in 4.0. Interesting.
In 3.5 all supported dictionaries work fine. In 4.0 WPF spell check works only for English language.
Edit 2
It's seems that it works only on 3.5 because I'm on Windows 7, so I don't need language packs.
The other problem is that it works only because the text is preset. Any text you enter will get it's language from current user settings.
I guess the solution to your problem would be to traverse the entire content and change it's Language properties each time the user selects a language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With