BindCommand with Key Press Events

42 views
Skip to first unread message

Brian Jenkins

unread,
Jul 10, 2015, 11:24:21 AM7/10/15
to reacti...@googlegroups.com
I have a TextBox and a Button for searching. When clicking the button, a search happens. I would like the search to happen when hitting the Enter Key inside the textbox as well. I am able to get this to work using the KeyUp Event on the textbox. I was wondering if there was another way to do this using the ReactiveUI framework.

this.BindCommand(ViewModel, x => x.SearchCommand, x => x.searchButton);

TextBoxSearch.KeyUp += delegate(object sender, KeyEventArgs args)

{

     if (args.Key == Key.Enter)

     {

          ViewModel.SearchCommand.Execute(null);

     }

};


I got this far, but couldn't figure out to make it work for just the Enter key.


this.BindCommand(ViewModel, x => x.SearchCommand, x => x.TextBoxSearch, "KeyUp");



Reply all
Reply to author
Forward
0 new messages