InputBinding.Command プロパティ

定義

この入力バインドに関連付けられる ICommand を取得または設定します。

public:
 property System::Windows::Input::ICommand ^ Command { System::Windows::Input::ICommand ^ get(); void set(System::Windows::Input::ICommand ^ value); };
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
public System.Windows.Input.ICommand Command { get; [System.Security.SecurityCritical] set; }
[System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)]
[System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public System.Windows.Input.ICommand Command { get; set; }
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)>]
[<set: System.Security.SecurityCritical>]
member this.Command : System.Windows.Input.ICommand with get, set
[<System.Windows.Localizability(System.Windows.LocalizationCategory.NeverLocalize)>]
[<System.ComponentModel.TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")>]
member this.Command : System.Windows.Input.ICommand with get, set
Public Property Command As ICommand

プロパティ値

関連付けられているコマンド。

属性

例外

Command 値は null です。

次の例は、 を使用 KeyBinding して コマンドに をバインド KeyGesture する方法を ApplicationCommands.Open 示しています。 キー ジェスチャが実行されると、Open コマンドが呼び出されます。

<Window.InputBindings>
  <KeyBinding Key="B"
              Modifiers="Control" 
              Command="ApplicationCommands.Open" />
</Window.InputBindings>
KeyGesture OpenKeyGesture = new KeyGesture(
    Key.B,
    ModifierKeys.Control);

KeyBinding OpenCmdKeybinding = new KeyBinding(
    ApplicationCommands.Open,
    OpenKeyGesture);

this.InputBindings.Add(OpenCmdKeybinding);
Dim OpenKeyGesture As New KeyGesture(Key.B, ModifierKeys.Control)

Dim OpenCmdKeybinding As New KeyBinding(ApplicationCommands.Open, OpenKeyGesture)

Me.InputBindings.Add(OpenCmdKeybinding)

注釈

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

ICommand は、既存の特定 ICommand の実装で文字列の形式で値を指定できるようにする型コンバーターを参照します。 この型変換動作は、このプロパティの属性値の形式を設定します。 、、および CommandTarget の各プロパティICommandCommandCommandParameter、オブジェクトで定義されている にバインドすることもできます。 これにより、カスタム コマンドを定義し、ユーザー入力に関連付けることができます。 詳細については、 の 2 番目の例を InputBinding参照してください。

XAML 属性の使用方法

<inputBindingDerivedClassCommand=""ICommand/>

XAML プロパティ要素の使用

<inputBindingDerivedClass>  
  <inputBindingDerivedClass.Command>  
    <iCommandImplementation/>  
  </inputBindingDerivedClass.Command>  
</inputBindingDerivedClass>  

XAML 値

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

iCommandImplementation
オブジェクト要素の ICommand 構文をサポートする のオブジェクト実装 (パブリック パラメーターなしのコンストラクターがあります)。

適用対象

こちらもご覧ください