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

属性

示例

以下示例演示如何使用 KeyBinding 将 绑定到 KeyGestureRoutedCommandKeyGesture按下 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。 是 KeyGesture 和一组 的组合KeyModifierKeys。 是 MouseGesture 和一组 的组合MouseActionModifierKeys

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

XAML 属性用法

<KeyBindingGesture=“KeyGesture”/>

-或-

<MouseBindingGesture=“MouseGesture”/>

-或-

<inputBindingDerivedClassGesture=“InputGesture”/>

XAML 属性元素用法

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

XAML 值

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

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

适用于

另请参阅