Spell- Checking Textbox in WPF using Expression Blend

The System.Windows.Controls.SpellCheck class provides real-time spell-checking functionality fortext-editing controls.

When enabled on a TextBox or RichTextBox control, as the user types text

into the control, any unrecognized words are underlined in red. If the user right-clicks a highlighted

word, they get a context menu, and they can select to replace the word from a set ofsuggested alternatives.

Windows.xaml

<Window

       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

       xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d" x:Class="SpellCheck.MainWindow"       x:Name="Window"

       Title="MainWindow" Width="400" Height="300">

 

       <Grid Height="300" Width="400">

       <Grid.Background>

           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

              <GradientStop Color="White"/>

              <GradientStop Color="#FF151518" Offset="0.778"/>

           </LinearGradientBrush>

       </Grid.Background>

 

<TextBlock FontSize="14" FontWeight="Bold" Text="A spell-checking TextBox:"  Height="28" VerticalAlignment="Top" Margin="19,17,194,0" Foreground="#FF0D0C0E">

       <TextBlock.Background>

           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

              <GradientStop Color="#FF121112" Offset="0.896"/>

              <GradientStop Color="#FFF1EAE7" Offset="0.478"/>

           </LinearGradientBrush>

       </TextBlock.Background>

       </TextBlock>

 

<TextBox Margin="19,53,26,85" TextWrapping="Wrap" SpellCheck.IsEnabled="True"  Foreground="Black"  Text="The qick red focks jumped over the lasy brown dog." BorderThickness="2" BorderBrush="#FF161312" FontSize="12" >

      <TextBox.Background>

           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

              <GradientStop Color="White" Offset="0"/>

              <GradientStop Color="White" Offset="1"/>

           </LinearGradientBrush>

       </TextBox.Background>

       </TextBox>

       </Grid>

</Window>

Ebook Download
View all
Learn
View all
F11Research & Development, LLC