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

How to: Register Custom Control to Enable Spell Checking

The following example describes how to implement the spell checker in custom or standard text controls (TextBox or RichTextBox).

Register Standard Text Control

  1. In XAML, configure the text control’s DXSpellChecker behavior.

    xmlns:mvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/spellchecker">
    <TextBox TextWrapping="Wrap" Text="TextBox" Grid.Column="1">            
                <mvvm:Interaction.Behaviors>
                    <dxsch:DXSpellChecker CheckAsYouType="True" ShowSpellCheckMenu="True" Culture="en-US"/>
                </mvvm:Interaction.Behaviors>
    </TextBox>
    
  2. In code-behind, register the control by calling the SpellingSettings.RegisterTextControl method.

    SpellingSettings.RegisterTextControl(typeof(TextBox));
    

Register the RichEditControl descendant

  1. In XAML, configure the custom control’s RichEditSpellChecker behavior.

    xmlns:mvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
    xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/spellchecker">
      <mvvm:Interaction.Behaviors>
          <dxsch:RichEditSpellChecker CheckAsYouType="True" ShowSpellCheckMenu="True" Culture="en-US"/>
      </mvvm:Interaction.Behaviors>
    
  2. To enable the Spelling dialog for the custom control, call the SpellCheckTextControllersManager.Default.RegisterClass method. This method requires the DevExpress.XtraSpellChecker.Native namespace reference. Call the SpellCheckTextBoxBaseFinderManager.Default.UnregisterClass method to disable spelling check.

    using DevExpress.XtraSpellChecker.Native;
    //...
    
    SpellCheckTextControllersManager.Default.RegisterClass(typeof(MyRichEditControl), typeof(DevExpress.XtraRichEdit.SpellChecker.RichEditSpellCheckController));