Silverlight TextBox TextChanged Event using C#
The TextChanged event of TextBox control in Silverlight is an event handler that occurs when a user changes the input text entered into the textbox. In this tutorial we will learn how to handle the TextChanged event of Silverlight TextBox control using C# code example. Let’s start it by adding a TextBox control onto the design view of Silverlight user control as we learnt in the previous tutorial: Silverlight TextBox control.
XAML Code before Adding TextChanged Event
After adding the textbox on the canvas at the desired place, double click the textbox. It will attach a TextChanged event handler and move you to the code view window automatically. The following code will be generated automatically when you will double click the textbox control in the design view layout of canvas:
<TextBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
C# Code Auto-generated
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
}
XAML Code after Attaching TextChanged Event
<TextBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" TextChanged="textBox1_TextChanged" />
For illustrating the use of text changed event we have used one more textbox control that can be placed at the right side of the first textbox control.
In the last step we have added a C# code statement to update the text property of second textbox control programmatically in the TextChanged event handler attached to the first control. The following code shows how to do it:
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
textBox2.Text = textBox1.Text.Length.ToString();
}

The above C# code will update the Text property value each time the user will type the input in the first textbox. It will display the length of text entered.

* will not be published
* hint: http://www.example.com