Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MouseGesture Class

Defines a mouse input gesture that can be used to invoke a command.

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

[TypeConverterAttribute(typeof(MouseGestureConverter))] 
public class MouseGesture : InputGesture
/** @attribute TypeConverterAttribute(System.Windows.Input.MouseGestureConverter) */ 
public class MouseGesture extends InputGesture
TypeConverterAttribute(System.Windows.Input.MouseGestureConverter) 
public class MouseGesture extends InputGesture
<MouseGesture .../>
<object property="mouseAction"/>
- or -
<object property="oneOrMoreModifierKeys"/>
- or -
<object property="mouseAction+oneOrMoreModifierKeys"/>

 mouseAction   MouseAction  A single mouse action.  For more information, see the MouseAction property.  oneOrMoreModifierKeys  One or more modifier keys, defined by the ModifierKeys enumeration, delimited with a "+" character.  For more information, see the Modifiers property. 

Unlike a KeyGesture, a MouseAction does not have to be paired with ModifierKeys to be a valid MouseGesture.

A MouseGesture can be bound to an ICommand through a MouseBinding so that the command is invoked when the MouseGesture occurs.

The following example shows to create a MouseGesture and associate it with a RoutedCommand through a MouseBinding. When the mouse wheel is clicked while the Control key is pressed, the Open is invoked.

<MouseBinding Gesture="Control+WheelClick"
              Command="ApplicationCommands.Open" />

MouseGesture OpenCmdMouseGesture = new MouseGesture();
OpenCmdMouseGesture.MouseAction = MouseAction.WheelClick;
OpenCmdMouseGesture.Modifiers = ModifierKeys.Control;

MouseBinding OpenCmdMouseBinding = new MouseBinding();
OpenCmdMouseBinding.Gesture = OpenCmdMouseGesture;
OpenCmdMouseBinding.Command = ApplicationCommands.Open;

this.InputBindings.Add(OpenCmdMouseBinding);

System.Object
   System.Windows.Input.InputGesture
    System.Windows.Input.MouseGesture

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft