public ref class MouseBinding : System::Windows::Input::InputBinding
public class MouseBinding : System.Windows.Input.InputBinding
type MouseBinding = class inherit InputBinding
Public Class MouseBinding Inherits InputBinding
<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)
A MouseBinding associates a MouseGesture with an ICommand implementation. RoutedCommand is the primary implementation of the ICommand interface for the WPF commanding system. In general, when the MouseGesture is executed, the command is invoked, although the command behavior is further influenced by command-specific factors such as the CanExecute value. For more information on commanding, see the Commanding Overview.
When defining a MouseBinding in Extensible Application Markup Language (XAML), there are two ways to specify the MouseGesture. The first way to establish a MouseBinding in XAML is to define the Gesture attribute of the MouseBinding element, which enables a syntax to specify mouse actions and modifiers as a single string; for example, "CTRL+LeftClick". The second way is to define the MouseAction attribute of the MouseBinding element. Both ways of setting the MouseGesture are equivalent and modify the same underlying object, but there will be a conflict if both are used. In the case when the MouseAction and the Gesture attributes are both set, the gesture is invalid. In general, it is recommended that you use only the Gesture attribute from XAML, even if you do not specify modifiers; this avoids ambiguity, provides the most streamlined syntax, and provides the most straightforward representation for serialization.
A MouseBinding can be defined on a specific object or at the class level by registering a RegisterClassInputBinding on the CommandManager class. The most typical way to define a MouseBinding is within the control template, setting the InputBindings property in XAML by declaring one or more MouseBinding or KeyBinding elements.
|MouseBinding() MouseBinding() MouseBinding() MouseBinding()||
Initializes a new instance of the MouseBinding class.
|MouseBinding(ICommand, MouseGesture) MouseBinding(ICommand, MouseGesture) MouseBinding(ICommand, MouseGesture) MouseBinding(ICommand, MouseGesture)||
Initializes a new instance of the MouseBinding class, using the specified command and mouse gesture.
|MouseActionProperty MouseActionProperty MouseActionProperty MouseActionProperty||
Identifies the MouseAction dependency property.
|Command Command Command Command||
Gets or sets the ICommand associated with this input binding.(Inherited from InputBinding)
|CommandParameter CommandParameter CommandParameter CommandParameter||
Gets or sets the command-specific data for a particular command.(Inherited from InputBinding)
|CommandTarget CommandTarget CommandTarget CommandTarget||
Gets or sets the target element of the command.(Inherited from InputBinding)
|DependencyObjectType DependencyObjectType DependencyObjectType DependencyObjectType||
Gets the DependencyObjectType that wraps the CLR type of this instance.(Inherited from DependencyObject)
|Dispatcher Dispatcher Dispatcher Dispatcher||DispatcherObject)|
|Gesture Gesture Gesture Gesture||
Gets or sets the gesture associated with this MouseBinding.
|IsSealed IsSealed IsSealed IsSealed||
Gets a value that indicates whether this instance is currently sealed (read-only).(Inherited from DependencyObject)
|MouseAction MouseAction MouseAction MouseAction|