code_junkie

Pressing Enter on TextBox in Silverlight

Nov 12th, 2011
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. private void MyTextBox_KeyUp(object sender, KeyEventArgs e)
  2. {
  3. if (e.Key == Key.Enter) SomeButton_Click(this, null);
  4.  
  5. }
  6.  
  7. private void SomeButton_Click(object sender, RoutedEventArgs e)
  8. {
  9. ICommand cmd = SomeButton.Command;
  10. if (cmd.CanExecute(null))
  11. {
  12. cmd.Execute(null);
  13. }
  14. }
Add Comment
Please, Sign In to add comment