TextBox Selection Model In Silverlight 4
In this article we will see the Text Selection Model in Silverlight 4.
Create Silverlight Application
Fire up Visual Studio 2010 and create a Silverlight Application and name the solution as TextSelection Model.
Let’s have the following design which would help us understand the TextBox Selection model.
As you see in above image the selection operation’s would be executed if any by the Execute Button. And the result would be displayed in the below textbox.
We will discuss several properties of the model.
Selection Background and Selection Foreground
These properties affect how the selection area would be displayed.
As you see in above image, the defalut is White in Black.
Let’s change it.
The following is the selection area style if changed as above.
This property is used to get or set the selected text in a Textbox.
Let’s see how we can use the property.
And the result is:
Selection Start and Selection Length
As the properties names are, Selection Start position would give the position and Selection Length would give the length of the selection.
Let’s just add the properties output to the above example.
And the result is :
Hope this article helps.