Wednesday, 18 July 2007

WPF (Windows Presentation Foundation) Control Part 1

Here is the good property add in XAML where you can easily start spell checking your textboxes or rich text boxes. Its is really useful when you are creating any web or windows based application where user tye comments and I found it in one my application which is web based very useful to use this property have a look here:

<TextBox SpellCheck.IsEnabled="True" />


Just using this property you can enable the spell checking wow that is the new era. For details here is the small project for the beginner which helps them to start learning the use of WPF control and how to enable spell checking.

1- Open the XAMLBrowserApplication from your Visual Studio 2005.

Note: You can also open Windows base but the code I am providing here is for web based

2- At this point one file is important for us to create this project i.e. Page1.xaml that is the file we do coding for XAML and for the code behind we use Page1.xaml.cs.

3- Copy and paste the following code between <Grid></Grid> code and press F5.

<StackPanel Margin="20">

<StackPanel Orientation="Horizontal">

<TextBlock FontWeight="Bold" FontSize="12">Type any text belowTextBlock>

StackPanel>

<StackPanel Orientation="Horizontal">

<TextBox SpellCheck.IsEnabled="True" TextWrapping="Wrap" AcceptsReturn="True"

VerticalScrollBarVisibility="Visible" Width="400" Height="200" Text="Typee anthinge which spell rong" BorderBrush="Black" />

StackPanel>

StackPanel>

The output is look alike this:


To correct the spelling just right click of your mouse after placing cursor on word it will give you popup like below :



You can download the code from here.


No comments: