WPF has built-in support for spellchecking. Unfortunately the SDK docs on the spellchecking features suck (to put it nicely). For example, it never even mentions which languages are supported by the spellchecker!
I just spent a few hours trying to come up with a slick way to provide spelling suggestions for misspelled words. I put the suggestions (which are provided by the spellchecking APIs) into a ListBox and then showed it in a Popup. After fiddling around trying getting it “just right” I discovered that the functionality already exists. The docs just never mention it…
Notice that if you bring up a context menu on a misspelled word, the menu lists suggestions for that word.
One way to enable the spellchecking functionality on a TextBox or RichTextBox is by setting SpellCheck’s IsEnabled attached property to true, like so:
<TextBox SpellCheck.IsEnabled=”True” />
Here’s a snippet of the code I was working on before I made the discovery. It takes the suggested words and shows them in a ListBox. This code would be useful if you wanted a portion of the UI to display suggestions, without requiring the user to open a context menu.
if( this.textBox.CaretIndex > 0 )
int idx = this.textBox.CaretIndex – 1;
SpellingError error = this.textBox.GetSpellingError( idx );
if( error != null )
this.listBox.ItemsSource = error.Suggestions;