KeyDown, KeyUp, and TextChanged events in Silverlight

Declare textbox with events:

<TextBox KeyDown="txt_KeyDown" KeyUp="txt_KeyUp" 
 TextChanged="txt_TextChanged"></TextBox>

C# Code behind to handle these events:

private void txt_KeyUp(object sender, KeyEventArgs e) 
{ 
    string message = 
      " KeyUp " + 
      " Key: " + e. Key; 
    lstMessages.Items.Add(message); 
} 
 
private void txt_KeyDown(object sender, KeyEventArgs e) 
{ 
    string message = 
      " KeyDown " + 
      " Key: " + e. Key; 
    lstMessages.Items.Add(message); 
} 
 
private void txt_TextChanged(object sender, TextChangedEventArgs e) 
{ 
    string message = "TextChanged"; 
    lstMessages.Items.Add(message); 
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.