Skip to main content
A newer version of this page is available. .

How to: Enable Spelling Check-As-You-Type for the Rich Edit Control

  • 2 minutes to read

This example demonstrates how to check the spelling of the text contained in a RichEditControl control.

A spell checker is the RichEditSpellChecker object, created and initialized in XAML. The behavior mechanism is used to add spelling check functionality to the RichEditControl. The RichEditSpellChecker instance is available at runtime using the RichEditControl.SpellChecker property.

Note

The color (red) and appearance (wavy) of the underline used in the RichEditControl are predefined and cannot be changed.

Note

A custom dictionary, specified in XAML, does not save words which the end-users add at runtime.

View Example

<Window
    x:Class="RichEditSpellChecker_Example.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:dxre="http://schemas.devexpress.com/winfx/2008/xaml/richedit"
    xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:dxspch="http://schemas.devexpress.com/winfx/2008/xaml/spellchecker"
    Height="350"
    Width="525"
    mc:Ignorable="d"
    Title="MainWindow">
    <Grid>
        <!--region #RichEditSpellCheckerBehavior-->
        <dxre:RichEditControl DocumentSource="An ideal dictionarie shouldbe comprised of all the the words in a given langauge">
            <dxmvvm:Interaction.Behaviors>
                <dxspch:RichEditSpellChecker CheckAsYouType="True"
                                             Culture="en-US"
                                             IgnoreMixedCaseWords="False"
                                             IgnoreUri="False"
                                             SpellingFormType="Word">
                    <dxspch:RichEditSpellChecker.Dictionaries>
                        <dxspch:HunspellDictionary Culture="en-US" 
                                                   DictionaryUri="pack://application:,,,/Dictionaries/en_US.dic"
                                                   GrammarUri="pack://application:,,,/Dictionaries/en_US.aff"/>
                        <dxspch:SpellCheckerCustomDictionary Culture="en-US"
                                                             DictionaryUri="Dictionaries/CustomEnglish.dic"
                                                             AlphabetUri="Dictionaries/EnglishAlphabet.txt"/>
                    </dxspch:RichEditSpellChecker.Dictionaries>
                </dxspch:RichEditSpellChecker>
            </dxmvvm:Interaction.Behaviors>
        </dxre:RichEditControl>
        <!--endregion #RichEditSpellCheckerBehavior-->
    </Grid>
</Window>