This documentation is archived and is not being maintained.

MouseBinding.Gesture Property

Gets or sets the gesture associated with this MouseBinding.

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 gesture.

Exception typeCondition


the value Gesture is being set to is a null reference (Nothing in Visual Basic).

A MouseGesture is a MouseAction with or without a set of ModifierKeys. Unlike a KeyGesture, a MouseGesture does not have to have a modifier key associated with it.

The following example show how to create a binding between a MouseGesture to a RoutedCommand.

<MouseBinding Gesture="Alt+MiddleClick"
              Command="ApplicationCommands.New" />

MouseGesture NewCmdMouseGesture = new MouseGesture();
NewCmdMouseGesture.Modifiers = ModifierKeys.Alt;
NewCmdMouseGesture.MouseAction = MouseAction.MiddleClick;

MouseBinding NewMouseBinding = new MouseBinding();
NewMouseBinding.Command = ApplicationCommands.New;
NewMouseBinding.Gesture = NewCmdMouseGesture;

// RootWindow is an instance of Window. 

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