Key Commands in WPF
How can I set key comma开发者_JAVA百科nds like if the user presses Ctrl + Shift + N, a new dialog or action happens. And do I have to make a new event for each key command? How can I do this?
You'll want to use the KeyBinding
class.
KeyBinding
allows you to bind a keyboard combination to any ICommand
, including a RoutedCommand
.
You can use the command framework provided for WPF. Some basic commands such as paste, copy, open, etc. are already defined by Microsoft...
You can, however, define new commands. A command can be executed when a button is clicked, a keyboard shortcut is pressed, a menu item is selected, etc.
I am no WPF guru, but my understanding is that using commands is the way to go.
Take a loot at MSDN: http://msdn.microsoft.com/en-us/library/ms752308.aspx
精彩评论