InputBinding.Gesture 属性

定义

获取或设置 InputGesture 与此输入绑定关联的项。

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

属性值

关联的手势。 默认值为 null

属性

示例

以下示例演示如何使用 a KeyBinding 绑定到 KeyGesture a RoutedCommand. KeyGesture按下 ALT+L 时,Close将调用该命令。

<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)

注解

输入手势是调用命令的操作。 WPF中输入手势的示例包括 KeyGestureMouseGesture。 A KeyGesture 是一 Key 组和一组 ModifierKeys的组合。 A MouseGesture 是一 MouseAction 组和一组 ModifierKeys的组合。

InputBinding 类本身不支持 XAML 用法,因为它不公开公共无参数构造函数(存在无参数构造函数,但它受到保护)。 但是,派生类可以公开公共构造函数,因此可以设置从 InputBinding XAML 用法继承的属性。 可以在 XAML 中实例化的两个现有InputBinding派生类,并且可以在 XAML 中设置属性。KeyBindingMouseBinding

XAML 属性用法

< KeyBinding Gesture=“”KeyGesture/>

-或-

< MouseBinding Gesture=“”MouseGesture/>

-或-

< inputBindingDerivedClass Gesture=“”InputGesture/>

XAML 属性元素用法

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

XAML 值

inputBindingDerivedClass 支持对象元素语法的派生类 InputBinding ,例如 KeyBindingMouseBinding。 请参阅“备注”。

inputGestureImplementation 一个支持对象元素语法的 InputGesture 自定义派生类。

适用于

另请参阅