开发者

Key Commands in WPF

开发者 https://www.devze.com 2022-12-17 08:22 出处:网络
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 w

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

0

精彩评论

暂无评论...
验证码 换一张
取 消