Skip to main content

How to: Bind Dictionaries to the Spell Checker in MVVM Applications

  • 4 minutes to read

This topic demonstrates how to bind dictionaries to the Spell Checker integrated into a supported text-aware control (RichEditControl, TextEdit, MemoEdit, TextBox, or RichTextBox).

Use Spell-Checking Behavior

You can implement spell-checking behavior to integrate the Spell Checker into a text editor. For more information, see Configure Spell-Checking Behavior.


We recommend that you use this approach to enable spell check for supported text-aware controls (RichEditControl, TextEdit, MemoEdit, TextBox, and RichTextBox) and add dictionaries to the Spell Checker.

After you attach spell-checking behavior to a text editor, add dictionaries to the SpellCheckerBase<T>.Dictionaries collection in XAML. The Spell Checker supports the Simple, ISpell, OpenOffice, and Hunspell dictionaries.

The following code sample shows how to add dictionaries to the DXSpellChecker integrated into the TextEdit control:

    <!-- ... -->
    <!-- ... -->
        <dxe:TextEdit Text="An ideal dictionarie shouldbe comprised of all the the words in a given langauge">
                <dxspch:DXSpellChecker x:Name="spChecker"
                        <dxspch:SpellCheckerISpellDictionary AlphabetUri="Dictionaries/EnglishAlphabet.txt" 


Note that the OpenOffice license cannot be used for commercial projects. Please ensure the relevant license agreement permits use within your application or project.

Use the SpellingSettings Option

You can also use the SpellingSettings option to integrate the Spell Checker into a supported text-aware control and bind dictionaries to the Spell Checker.

In the ViewModel, create a SpellChecker class instance and specify its Culture, SpellingFormType, and SpellCheckMode properties. Create a dictionary collection (DictionarySourceCollection) and add a new dictionary to it. Specify the dictionary file, the affix file, and the culture settings of the dictionary.

View Example

using DevExpress.Xpf.SpellChecker;
using DevExpress.XtraSpellChecker;
// ...
public class MainViewModel
    public virtual DictionarySourceCollection Dictionaries { get; set; }
    public virtual SpellChecker SpellChecker { get; set; }

    public MainViewModel()
        // Create a SpellChecker class instance.
        SpellChecker = new SpellChecker();
        // Specify the SpellChecker's properties.
        SpellChecker.SpellingFormType = SpellingFormType.Word;
        SpellChecker.SpellCheckMode = SpellCheckMode.AsYouType;
        SpellChecker.Culture = new CultureInfo("de-DE");
        // Obtain a dictionary collection.
        Dictionaries = GetDictionaries();

    public DictionarySourceCollection GetDictionaries()
        // Create a dictionary collection.
        var collection = new DictionarySourceCollection();
        // Create a Hunspell spell-checking dictionary.
        var dictionary = new HunspellDictionarySource();
        // Specify the dictionary culture settings.
        dictionary.Culture = new CultureInfo("de-DE");
        // Load the dictionary file.
        dictionary.DictionaryUri = new Uri(@"pack://application:,,,/DXSpellCheckerBindingDictionaries;component/Dictionaries/de_DE.dic");
        // Load the affix file.
        dictionary.GrammarUri = new Uri(@"pack://application:,,,/DXSpellCheckerBindingDictionaries;component/Dictionaries/de_DE.aff");
        // Add the dictionary to the collection.
        return collection;

In XAML, bind the created SpellChecker object to the SpellingSettings.SpellChecker property to enable spell check for a text editor. Specify the SpellingSettings attributes applied to the text editor. Bind the dictionary collection to the SpellingSettings.DictionarySourceCollection property to add dictionaries to the Spell Checker.

The code sample below binds dictionaries to the Spell Checker integrated into the TextEdit control:

<Window xmlns=""
<!-- ... -->
        <!-- ... -->
        <!-- ... -->
        <!-- ... -->
    <!-- ... -->
        <dxe:TextEdit x:Name="textEdit1"
                      Text=" Das Regcht hat viele Funktionem. Die wichtigste darunter ist die Sicherung des Friedens im Lande."
                      dxsch:SpellingSettings.DictionarySourceCollection="{Binding Dictionaries,UpdateSourceTrigger=PropertyChanged}"/>

            <Binding Path="SpellChecker"/>
        <!-- ... -->
    <!-- ... -->
See Also