The Spell Checker functionality is very useful. In
this article, We will see how to use spell checker in WPF application. This
functionality use for check spelling all type in English. I have explored
the SpellCheck functionality of WPF TextBoxBase object.
We will set SpellCheck.IsEnabled="True" property
in the textbox after that automatically derive the Spell Checking functionality.
This code is .xaml:-
<Window
x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1"
Height="300"
Width="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="30"></RowDefinition>
<RowDefinition
Height="100"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="30"></ColumnDefinition>
<ColumnDefinition
Width="75"></ColumnDefinition>
<ColumnDefinition
Width="150"></ColumnDefinition>
<ColumnDefinition
Width="30"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid
Grid.Row="1"
Grid.Column="1">
<TextBlock
x:Name="txtSpellMessage"
FontSize="15"
Text="Comment:"
Margin="0,32,0,0"></TextBlock>
</Grid>
<Grid
Grid.Row="1"
Grid.Column="2"
Grid.RowSpan="2">
<TextBox
x:Name="txtSpellCheck"
FontSize="15"
SpellCheck.IsEnabled="True"
AcceptsReturn="True"
Width="175"
Height="150"></TextBox>
</Grid>
</Grid>
</Window>
After run the application we will see the
TextBox txtSpellCheck, have
SpellChecker enabled. We type wrong spelling in
the textbox automatically detect misspelled words and will put an red underline
on the word.
We can easily spelling check in this application
throw. If we right click on this word then a list of words is shown. We can
select the correct word from the list available with us.
Output:-
