WPF Keyboard Shortcuts for Custom Commands

So, I am programming an application in WPF / C #, and currently I am using this method of handling quick keystrokes. And I hate him so much.

private void MainWnd_KeyDown(object sender, KeyEventArgs e) if (e.Key == Key.F1 && Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) { DoCtrlF1Function(); } 

Now, no doubt, I would use command bindings, but in XAML, if I put the name and not the built-in, I get an exception using the WPF editor. Is there a better way to do this (e.g. add my own commands, will it look like RoutedCommand?)

+4
source share
1 answer

http://www.informit.com/articles/article.aspx?p=688529&seqNum=4

Scroll down to the section "Executing commands using input gestures", it gives a good overview of how to configure global keyboard shortcuts.

+2
source

Source: https://habr.com/ru/post/1341389/


All Articles