Language

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 を使用して KeyGesture を 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の入力ジェスチャの例としては、KeyGesture と MouseGestureがあります。 KeyGestureは、Keyと一連のModifierKeysの組み合わせです。 MouseGestureは、MouseActionと一連のModifierKeysの組み合わせです。

InputBinding クラス自体は、パブリック パラメーターなしのコンストラクターを公開しないため、XAML の使用をサポートしていません (パラメーターなしのコンストラクターがありますが、保護されています)。 ただし、派生クラスはパブリック コンストラクターを公開できるため、XAML を使用して InputBinding から継承されるプロパティを設定できます。 XAML でインスタンス化でき、XAML でプロパティを設定できる 2 つの既存の InputBinding 派生クラスは、 KeyBinding と MouseBinding。

XAML 属性の使用法

< KeyBinding Gesture="KeyGesture"/>

-又は-

< MouseBinding Gesture="MouseGesture"/>

-又は-

< inputBindingDerivedClass Gesture="InputGesture"/>

XAML プロパティ要素の使用法

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

XAML 値

inputBindingDerivedClass InputBindingやKeyBindingなど、オブジェクト要素の構文をサポートするMouseBindingの派生クラス。 「解説」を参照してください。

inputGestureImplementation オブジェクト要素の構文をサポートする InputGesture のカスタム派生クラス。

適用対象

こちらもご覧ください