Defines a mouse input gesture that can be used to invoke a command.
public ref class MouseGesture : System::Windows::Input::InputGesture
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.MouseGestureConverter))] public class MouseGesture : System.Windows.Input.InputGesture
type MouseGesture = class inherit InputGesture
Public Class MouseGesture Inherits InputGesture
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);
Dim OpenCmdMouseGesture As New MouseGesture() OpenCmdMouseGesture.MouseAction = MouseAction.WheelClick OpenCmdMouseGesture.Modifiers = ModifierKeys.Control Dim OpenCmdMouseBinding As New MouseBinding() OpenCmdMouseBinding.Gesture = OpenCmdMouseGesture OpenCmdMouseBinding.Command = ApplicationCommands.Open Me.InputBindings.Add(OpenCmdMouseBinding)
For MouseGesture XAML attribute usages, the property that is generally set in XAML is Gesture, in cases where the gesture can represent both a mouse action and one or more modifier key. You can also set the Gesture property to be just a mouse action. In general, it is recommended that you use only the Gesture attribute from XAML, rather than setting MouseAction, even if you do not specify modifiers. This will avoid ambiguity, provides the most streamlined syntax, and provides the most straightforward representation for serialization.
XAML Attribute Usage
<object property="mouseAction"/> - or - <object property="oneOrMoreModifierKeys+mouseAction"/>
A single mouse action.
One or more modifier keys, defined by the ModifierKeys enumeration. If more than one modifier key is provided, each modifier key is delimited with a "+" character.
Initializes a new instance of the MouseGesture class.
Gets or sets the modifier keys associated with this MouseGesture.
Gets or sets the MouseAction associated with this gesture.
Determines whether the specified object is equal to the current object.(Inherited from Object)
Serves as the default hash function.(Inherited from Object)
Gets the Type of the current instance.(Inherited from Object)
Creates a shallow copy of the current Object.(Inherited from Object)
Returns a string that represents the current object.(Inherited from Object)