I\'m using the RelayCommand in my app. It\'s great for putting the code in the viewmodel, but how do I bind keystrokes to my command?
RoutedUICommand has its InputGe
I create a Key binding in my view model that links the command and the Key like so
this.KeyBinding = new KeyBinding();
//set the properties
this.KeyBinding.Command = this.Command;
this.KeyBinding.Key = this.Key;
//modifier keys may or may not be set
this.KeyBinding.Modifiers = this.ModifierKeys;
then i create a collection of InputBinding items in my View Model root and add them to the windows InputBindings in my window's code behind
foreach (var item in applicationViewModel.InputBindingCollection) {
this.InputBindings.Add(item);
}
its bad form to do stuff in the code behind i know, but i dont know how to do the binding yet, however im still working on it. :) The only thing this doent give me is a key command modifer list in the menu, but that is to come.