Ankesh
Ankesh

Reputation: 4885

Multiple KeyBinding like Visual Studio in WPF

I have tried to read many posts on StackOverflow about how to implement the KeyBinding like Visual Studio Ctrl+Shift+ A or Ctrl+K,Ctrl+C but no luck

I have found this article on on blogspot regarding Multiple Keybinding but it makes multiple gesture like Ctrl + A,B

Is it possible to make a Keybinding that flexible like (VS Studio) through XAML Syantax.

Upvotes: 4

Views: 1989

Answers (2)

purvin
purvin

Reputation: 144

    <KeyBinding x:Name="mykeybinding" Gesture="CTRL+E" Key="P" 
                Command="commandname"/>

Seems to be working ok for me you have to press ctrl+E+P to execute command.

Based on http://msdn.microsoft.com/en-in/library/system.windows.input.keybinding.aspx

Upvotes: 0

N8allan
N8allan

Reputation: 2268

Sequence key combo's like VS has are not natively part of WPF and most other UI frameworks. The reason being that such combos hail from text editors of the Jurassic era and survive only in a few modern contexts where users of said era still survive and even thrive. ;-)

You should be able to provide your own handling mechanisms for this in a fairly straight forward manner:

  • Build a mechanism to parse and represent these combos.
  • Provide key handling logic that recognizes the beginning of the sequence and goes into compound key mode
  • Provide a cue to the user when in combo mode
  • Adapt your key handling when in combo mode

Ideally you'll associate these combos command so there is no disparity between singles and combos.

Upvotes: 3

Related Questions