Click here to Skip to main content
11,485,294 members (77,386 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#

I want to create shortcuts for menus in WPF with two keys like that of Visual Studio

However I am able to create shortcuts using one key using below line of code,

this.InputBindings.Add(new KeyBinding(KeyBoardCommands.Open, new KeyGesture(Key.M, ModifierKeys.Control, "Ctrl+M")));

where KeyBoardCommands is the class in which I have defined the routed event Open.
this works fine for me. But I want to add support two keys with one modifier.
Please help me if anyone has any idea about it.

Posted 9-Nov-12 0:44am
Thomas Duwe at 13-Nov-12 3:32am
I don't think this is something that can be done using only inputbindings.
What comes to mind is something like this: if user presses Ctrl+M, save the state and if the user presses again an M, then execute the appropiate command.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 460
1 Maciej Los 360
2 Mehdi Gholam 150
3 Raje_ 145
4 Frankie-C 134
0 Sergey Alexandrovich Kryukov 8,819
1 OriginalGriff 7,982
2 Sascha Lefèvre 3,199
3 Maciej Los 2,841
4 Richard Deeming 2,370

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100