KeyBinding.Gesture 属性

定义

获取或设置与此关联的 KeyBinding手势。

public:
 virtual property System::Windows::Input::InputGesture ^ Gesture { System::Windows::Input::InputGesture ^ get(); void set(System::Windows::Input::InputGesture ^ value); };
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.KeyGestureConverter))]
public override System.Windows.Input.InputGesture Gesture { get; set; }
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Input.KeyGestureConverter))>]
member this.Gesture : System.Windows.Input.InputGesture with get, set
Public Overrides Property Gesture As InputGesture

属性值

键序列。 默认值为 null

属性

例外

gesture值设置为不是 KeyGesture

示例

下面的示例演示如何使用 /> 绑定到 (标记和代码示例指定不同的键,但在其他情况下是等效的)。

<Window.InputBindings>
  <KeyBinding Command="ApplicationCommands.Open"
              Gesture="CTRL+R" />
</Window.InputBindings>
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)

注解

除了函数键和数字键盘键外,必须 KeyGesture 包含一 Key 个或多个 ModifierKeys

适用于

另请参阅