This documentation is archived and is not being maintained.

KeyBinding.Gesture Property

Gets or sets the gesture associated with this KeyBinding.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public override InputGesture Gesture { get; set; }
/** @property */
public InputGesture get_Gesture ()

/** @property */
public void set_Gesture (InputGesture value)

public override function get Gesture () : InputGesture

public override function set Gesture (value : InputGesture)

For XAML information, see the InputGesture type.

Property Value

The key sequence. The default value is a null reference (Nothing in Visual Basic).

Exception typeCondition


the value gesture is being set to is not a KeyGesture.

With the exception of the function keys and the numeric keypad keys, a KeyGesture must contain a Key and one or more ModifierKeys.

The following example shows how to bind a KeyGesture to a RoutedCommand using a KeyBinding.

<KeyBinding Modifiers="Alt"
            Command="ApplicationCommands.Close" />

KeyGesture CloseCmdKeyGesture = new KeyGesture(
    Key.L, ModifierKeys.Alt);

KeyBinding CloseKeyBinding = new KeyBinding(
    ApplicationCommands.Close, CloseCmdKeyGesture);


Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0