# Open the Spell Check Dialog

> Open a spelling dialog for a WPF TextControl from the context menu or a XAML button with TextControl.SpellCheckDialog or the customizable SpellCheckDialog.Show.

- **Product:** TX Spell .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Spell .NET for WPF > Getting Started > TX Text Control > Open the Spell Check Dialog
- **1569 words**
- **Web URL:** https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/dialog/
- **LLMs URL:** https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/dialog/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/dialog/llms-full.txt

---

Underlines point out mistakes one at a time; a spelling dialog goes through all of them in order. With TX Spell .NET connected, the user can open a dialog from the context menu or from a button of yours, and correct the whole document word by word. You add a **Check Spelling** button to the application of [Create Your First WPF Application](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/first-application/llms-full.txt) and try both dialogs that are available.

### Prerequisites

- The application of [Create Your First WPF Application](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/first-application/llms-full.txt) or [Create a .NET Framework Application](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/dotnet-framework/llms-full.txt): a `TextControl` called *textControl1*, connected to a `TXSpellChecker` resource with the key *txSpellChecker1*.

### Open the Dialog Without Code

The application already offers the dialog: right-click an underlined word and click **Spell Check Dialog...**, as [Correct Words from the Context Menu](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/context-menu/llms-full.txt) shows.

With the ribbon of TX Text Control, the **Proofing** tab, a [RibbonProofingTab](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/ribbonproofingtab/llms-full.txt), holds the spelling and hyphenation buttons as well. These buttons work only when the `TextControl` has a spell checker connected.

### Add a Check Spelling Button

For a check started by the user, or before the document is saved, open the dialog in code:

1. In *MainWindow.xaml*, add a `Button` above the `TextControl` inside the `DockPanel`. Controls are docked in the order they appear, so place it before the `TextControl`:

    ```xml
    <Button x:Name="buttonSpelling" DockPanel.Dock="Top" Content="Check Spelling"
            Click="buttonSpelling_Click" />
    ```
2. In *MainWindow.xaml.cs*, add the handler and call the [SpellCheckDialog](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/spellcheckdialog-method/llms-full.txt) method of the `TextControl`:

```csharp
private void buttonSpelling_Click(object sender, RoutedEventArgs e)
{
    // Open the spelling dialog of TX Text Control
    textControl1.SpellCheckDialog();
}
```

1. Press **F5**, type a few misspelled words and click **Check Spelling**.

The dialog steps through all misspelled words of the document: the main text first, then the headers, footers and text frames. `SpellCheckDialog` works only when a spell checker is connected through the `SpellChecker` property.

### Use the Customizable Dialog of TX Spell .NET

The dialog that `SpellCheckDialog` opens belongs to TX Text Control and can't be changed. TX Spell .NET has a dialog of its own, which works the same way but can be customized: buttons can be added, removed or relabeled, and your code is notified of every change. Open it with the [SpellCheckDialog](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/txspellchecker/spellcheckdialog-property/llms-full.txt) property of the spell checker.

The spell checker is a resource of the window, so the code-behind gets it with `FindResource` first. The class below replaces the button handler of the previous section:

```csharp
using System.Windows;
using TXTextControl.WPF.Proofing;

public partial class MainWindow : Window
{
    private readonly TXSpellChecker txSpellChecker1;

    public MainWindow()
    {
        InitializeComponent();

        // The spell checker declared in Window.Resources
        txSpellChecker1 = (TXSpellChecker)FindResource("txSpellChecker1");
    }

    private void buttonSpelling_Click(object sender, RoutedEventArgs e)
    {
        // Open the customizable dialog of TX Spell .NET for this TextControl
        txSpellChecker1.SpellCheckDialog.Show(textControl1);
    }
}
```

Keep the `namespace` that Visual Studio created around the class. [Show](https://docs.textcontrol.com/tx-spell-dotnet-wpf/reference/txtextcontrol-wpf-proofing/spellcheckdialog/show-method/llms-full.txt) takes the `TextControl` to check. The dialog applies the corrections to the document itself, so no further code is needed:

![The Spelling dialog of TX Spell .NET over a TextControl, with the misspelled word "sampke" in its sentence, the suggestions, the Suggestions Dictionary en_US.dic and the buttons Ignore Once, Ignore All, Add To Dictionary, Change, Change All, Options and Cancel.](https://docs.textcontrol.com/assets/img/tx-spell-dotnet-wpf/textcontrol-spelling-dialog.0a7b34fc.webp)

It shows the language of the word above the sentence and, below the suggestions, a **Suggestions Dictionary** list, which chooses the dictionary the suggestions come from when several are loaded. **Options...** opens the options dialog.

### Correct the Words in the Dialog

The dialog of TX Spell .NET shows the misspelled word in its sentence and the suggestions below. For each word, the user chooses what to do:

1. Select a suggestion and click **Change** to replace this occurrence, or **Change All** to replace every occurrence of the word.
2. Click **Ignore Once** to skip this occurrence, or **Ignore All** to skip every occurrence.
3. Click **Add To Dictionary** to accept the word for good. This needs an editable user dictionary; see [User Dictionaries](https://docs.textcontrol.com/tx-spell-dotnet-wpf/dictionaries/user/llms-full.txt).
4. Click **Cancel** to stop before the end.

The dialog then moves on to the next misspelled word.

The *TextControl\\SpellCheckDialog* sample of the setup is built this way; [Spell Checking Examples](https://docs.textcontrol.com/tx-spell-dotnet-wpf/examples/spell-checking/llms-full.txt) lists where it is installed.

### Next Steps

- [Checking on Demand](https://docs.textcontrol.com/tx-spell-dotnet-wpf/spell-checking/on-demand/llms-full.txt): compare the two dialogs and control how a check ends.
- [Spell Check Dialog](https://docs.textcontrol.com/tx-spell-dotnet-wpf/user-interface/spell-check-dialog/llms-full.txt): every part of the dialog of TX Spell .NET.
- [Customizing the Spell Check Dialog](https://docs.textcontrol.com/tx-spell-dotnet-wpf/user-interface/customizing-dialog/llms-full.txt): add, remove and relabel its buttons.
- [Checking Multiple Controls](https://docs.textcontrol.com/tx-spell-dotnet-wpf/spell-checking/multiple-controls/llms-full.txt): check several editors in one dialog.

---

## Nearby

- **Previous:** [Correct Words From the Context Menu](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/tx-text-control/context-menu/llms-full.txt)
- **Next:** [RichTextBox](https://docs.textcontrol.com/tx-spell-dotnet-wpf/getting-started/richtextbox/llms-full.txt)
