Click here to Skip to main content
11,572,251 members (44,149 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 8-Nov-12 23:44pm
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

Advertise | Privacy | Mobile
Web03 | 2.8.150624.2 | 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