InputBinding.Gesture 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置与此输入绑定关联的 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 将 绑定到 KeyGestureRoutedCommand。 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 中的输入手势的示例包括 KeyGesture 和 MouseGesture。 是 KeyGesture 和一组 的组合KeyModifierKeys。 是 MouseGesture 和一组 的组合MouseActionModifierKeys。
类 InputBinding 本身不支持 XAML 用法,因为它不公开公共无参数构造函数 (无参数构造函数,但它) 受保护。 但是,派生类可以公开公共构造函数,因此可以设置使用 XAML 用法从 InputBinding 继承的属性。 可以在 XAML 中实例化并且可以在 XAML 中设置属性的两个现有 InputBinding 派生类是 KeyBinding 和 MouseBinding。
XAML 属性用法
<KeyBindingGesture
=“KeyGesture”/>
-或-
<MouseBindingGesture
=“MouseGesture”/>
-或-
<inputBindingDerivedClass
Gesture
=“InputGesture”/>
XAML 属性元素用法
<inputBindingDerivedClass>
<inputBindingDerivedClass.Gesture>
<inputGestureImplementation/>
</inputBindingDerivedClass.Gesture>
</inputBindingDerivedClass>
XAML 值
inputBindingDerivedClass
的派生类 InputBinding ,它支持对象元素语法,例如 KeyBinding 或 MouseBinding。 请参阅“备注”。
inputGestureImplementation
的自定义派生类 InputGesture ,支持对象元素语法。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈