Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MouseBinding.Gesture Property

Gets or sets the gesture associated with this MouseBinding.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[TypeConverterAttribute(typeof(MouseGestureConverter))] 
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

ArgumentException

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. 
RootWindow.InputBindings.Add(NewMouseBinding);

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

Community Additions

ADD
Show:
© 2015 Microsoft