RichTextBox for WPF | ComponentOne
WPF RichTextBox Quick Start / Step 2: Adding Spell-Check Functionality
In This Topic
    Step 2: Adding Spell-Check Functionality
    In This Topic

    In the previous step, you created a new application and added the RichTextBox and RichTextBoxToolbar controls to the application. If you currently click the Spell Check button in the toolbar at runtime, you receive a message that spell checking is currently not set up. In this step, you customize the application further and add spell-checking functionality to the application.

    To add spell checking to the application, complete the following steps:

    1. In the Solution Explorer, right-click the project and select Add | Existing Item.
    2. In the Add Existing Item dialog, locate the C1Spell_en-US.dct file that can be found in the installed folder at the following location: C:\...\Documents\ComponentOne Samples\WPF\C1.WPF.RichTextBox\CS\RichTextBoxSamples\Resources
       This is a US English dictionary file – if you add another file, instead, you can adapt the steps below with the appropriate code.
    3. In the Solution Explorer, right-click the MainPage.xaml file and select View Code to open the code file.
    4. In the code editor, add the required import statements.
      Imports C1.WPF.RichTextBox
      Imports C1.WPF.SpellChecker
      
      using C1.WPF.RichTextBox;
      using C1.WPF.SpellChecker;
      
    5. Add code to the MainPage constructor to add spell-check functionality in the RichTextBox control.
      InitializeComponent()
      Dim spell = New C1SpellChecker()
      spell.MainDictionary.LoadAsync("C1Spell_en-US.dct")
      Me.c1RichTextBox1.SpellChecker = spell
      
      InitializeComponent();
      var spell = new C1SpellChecker();
      spell.MainDictionary.LoadAsync("C1Spell_en-US.dct");
      this.c1RichTextBox1.SpellChecker = spell;
      
    6. Set the Text property for RichTextBox control to add content for spell checking.
      Me.c1RichTextBox1.Text = "Hello World! Weelcome to the most complete rich text editor availible for WPF. Load, edit, and save formattted text as HTML or RTF documents with ComponentOne RichTextBox for WPF. The C1RichTextBox control provids rich formatting, automatic line wrapping, HTML and RTF import/export, table support, images, anotations, and more."
      
      this.c1RichTextBox1.Text = "Hello World! Weelcome to the most complete rich text editor availible for WPF. Load, edit, and save formattted text as HTML or RTF documents with ComponentOne RichTextBox for WPF. The C1RichTextBox control provids rich formatting, automatic line wrapping, HTML and RTF import/export, table support, images, anotations, and more.";