#1,087 – Associating a Key Binding with Multiple Modifier Keys

You define a KeyBinding object to bind a key gesture (i.e. keypress) to a particular command.  You can do this in XAML by defining a <KeyBinding> element, associating a routed command with a key “gesture”.  The gesture indicates the key that you can press in order to execute the command.

Key gestures typically require associating a key with at least one of the modifier keys (Ctrl, Alt, Shift, or Windows key).  For example, Ctrl+O is specified as:

        <KeyBinding Command="ApplicationCommands.Open"
                    Gesture="Ctrl+O"/>

You can also combine modifier keys, using the “+” symbol.

        <KeyBinding Command="ApplicationCommands.Open"
                    Gesture="Ctrl+Alt+O"/>

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #1,087 – Associating a Key Binding with Multiple Modifier Keys

  1. Pingback: Dew Drop – June 5, 2014 (#1791) | Morning Dew

  2. Anjum says:

    How to assign VS2010 like keybinding like Ctrl+W,J ? That is pressing Ctrl + W and then pressing J while keeping Ctrl+W pressed to view Object browser.

Leave a comment