InputBinding.Gesture Property

Definition

Gets or sets the InputGesture associated with this input binding.

public:
 virtual property System::Windows::Input::InputGesture ^ Gesture { System::Windows::Input::InputGesture ^ get(); void set(System::Windows::Input::InputGesture ^ value); };
public virtual System.Windows.Input.InputGesture Gesture { get; [System.Security.SecurityCritical] set; }
public virtual System.Windows.Input.InputGesture Gesture { get; set; }
[<set: System.Security.SecurityCritical>]
member this.Gesture : System.Windows.Input.InputGesture with get, set
member this.Gesture : System.Windows.Input.InputGesture with get, set
Public Overridable Property Gesture As InputGesture

Property Value

The associated gesture. The default is null.

Attributes

Examples

The following example shows how to use a KeyBinding to bind a KeyGesture to a RoutedCommand. When the KeyGesture ALT+L is pressed, the Close command is invoked.

<KeyBinding Modifiers="Alt"
            Key="L"
            Command="ApplicationCommands.Close" />
KeyGesture CloseCmdKeyGesture = new KeyGesture(
    Key.L, ModifierKeys.Alt);

KeyBinding CloseKeyBinding = new KeyBinding(
    ApplicationCommands.Close, CloseCmdKeyGesture);

this.InputBindings.Add(CloseKeyBinding);
Dim CloseCmdKeyGesture As New KeyGesture(Key.L, ModifierKeys.Alt)

Dim CloseKeyBinding As New KeyBinding(ApplicationCommands.Close, CloseCmdKeyGesture)

Me.InputBindings.Add(CloseKeyBinding)

Remarks

The input gesture is the action that invokes the command. Examples of input gestures in WPF are KeyGesture and MouseGesture. A KeyGesture is a combination of a Key and a set of ModifierKeys. A MouseGesture is a combination of a MouseAction and a set of ModifierKeys.

The InputBinding class itself does not support XAML usage, because it does not expose a public parameterless constructor (there is a parameterless constructor, but it is protected). However, derived classes can expose a public constructor and thus can set properties that are inherited from InputBinding with a XAML usage. Two existing InputBinding derived classes that can be instantiated in XAML and can set properties in XAML are KeyBinding and MouseBinding.

XAML Attribute Usage

<KeyBinding Gesture="KeyGesture"/>

-or-

<MouseBinding Gesture="MouseGesture"/>

-or-

<inputBindingDerivedClass Gesture="InputGesture"/>

XAML Property Element Usage

<inputBindingDerivedClass>  
  <inputBindingDerivedClass.Gesture>  
    <inputGestureImplementation/>  
  </inputBindingDerivedClass.Gesture>  
</inputBindingDerivedClass>  

XAML Values

inputBindingDerivedClass
A derived class of InputBinding that supports object element syntax, such as KeyBinding or MouseBinding. See Remarks.

inputGestureImplementation
A custom derived class of InputGesture that supports object element syntax.

Applies to

See also