WPF : TextBox

Text in WPF can be handled in. many ways, basically there are three types

  • The Simple text box or the plain text box
  • The Rich text box.
The two types mentioned above share the same base class the TextBoxBase.
The Simple text box or the plain text box allows you to enter only simple string. If you want to format your string. you have to use the  Rich text box. which allows you to have formatted text/ string. The Rich text box doesnot use the RTF / Rich text format even if the name suggests you so. it uses the WPF's own flow formatting to format the text.
Even though it supports RTF, it just doesn't use it as its internal model.
As they support a common base class they support the common clipboard operations like copying editing and pasting etc.

There is another type of text box that doesn't share the same base 

  • The Password Box
This is as the name suggests used for the password entering purpose . it doesn't share the same base class as the above two. because it is required that it shouldn't support some of the clip board operations like copy and paste. it also shows the entered text as dots/stars etc.

The TextBox and the RichTextBox both support spell checking. 
All we have to do is set the property SpellCheck.IsEnabled ="True"


<Page 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
  
   <Grid>
<TextBox   SpellCheck.IsEnabled ="True" />

   </Grid>
</Page>

You can see below that the spell check works as expected, the misspelled words have been underlined with red. it can be right clicked to select from a list of words.

Again it depends on the localization. and provides the options depending on it.

The Example shown below is been developed on XamlPadX.
You can download this from http://blogs.msdn.com/b/llobo/archive/2006/12/30/xamlpadx-v2.aspx









1 comment: