It is very easy to bind Button in WPF applications to Command in the VIEWMODEL class. I would like to get a similar binding for a TextBox .
I have a TextBox and I need to bind it to a Command that fires when I press Enter while the TextBox focused. I am currently using the following handler for the KeyUp event, but it looks ugly ... and I cannot put it in the VIEWMODEL class.
private void TextBox_KeyUp(object sender, KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.Enter) {
Is there a better way to do this?
Aryan SuryaWansi Jul 30 '11 at 9:11 2011-07-30 09:11
source share