One can define a shortcut in WPF with
<KeyBinding Key="N" Modifiers="Control" Command="local:CustomCommands.MyCommand"/>
Shortcut CTRL + N
is now defined.
Question: Is it also possible to define a double-key shortcut like Visual Studio 2012 uses it?
Example: CTRL + R, A
is used to execute all unit tests.
Use Gesture in conjunction with Key instead of modifier. As per MSDN:
When defining a KeyBinding in Extensible Application Markup Language (XAML) there are two ways to specify the KeyGesture. The first way to establish a KeyBinding in XAML is to define the Gesture attribute of the KeyBinding element, which enables a syntax to specify keys and modifiers as a single string, for example "CTRL+P". The second way is to define the Key attribute and the Modifiers attributes of the KeyBinding element.
<KeyBinding Gesture="Control+R" Key="A"
Command="local:CustomCommands.MyCommand"/>
This will execute MyCommand
in case Ctrl+R,A
combination is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With