简体   繁体   中英

Key Commands in WPF

How can I set key commands 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM