共用方式為


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

範例

下列範例示範如何使用標記和程式代碼範例 (來系結 KeyGestureRoutedCommandKeyBinding ,但指定不同的索引鍵,否則為相等) 。

<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

適用於

另請參閱