The KeyToCommand class is a special behavior that allows you to bind a KeyGesture to a command.
Getting Started with KeyToCommand
Assume that there is a requirement to handle a the key gesture of a control. For example, you need to invoke the ViewModel's CommitCommand when the end-user presses the Enter key while the focus is in the TextBox.
Note that KeyToCommand uses the KeyUp event to handle KeyGestures by default. If necessary, you can specify any other event here, for example, KeyDown.
Due to the fact that the KeyToCommand and EventToCommand are inherited from one base class, their overall capabilities are similar to ProcessEventsFromDisabledEventOwner, MarkRoutedEventsAsHandled, UseDispatcher and DispatcherPriority.
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.