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 바인딩 KeyGestureApplicationCommands.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 사용으로 속성을 설정할 수 있는 두 개의 기존 InputBinding 파생 클래스는 및 MouseBinding입니다KeyBinding.

ICommand 는 특정 기존 ICommand 구현이 문자열 형식의 값을 지정할 수 있도록 하는 형식 변환기를 참조합니다. 이 형식 변환 동작은 이 속성의 특성 값 형식을 설정합니다. 개체에 Command정의된 에 , CommandParameterCommandTarget 속성을 바인딩할 ICommand 수도 있습니다. 이렇게 하면 사용자 지정 명령을 정의하고 사용자 입력과 연결할 수 있습니다. 자세한 내용은 의 두 번째 예제를 참조하세요 InputBinding.

XAML 특성 사용

<inputBindingDerivedClassCommand="ICommand"/>

XAML 속성 요소 사용

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

XAML 값

inputBindingDerivedClass
또는 MouseBinding와 같은 KeyBinding 개체 요소 구문을 지원하는 의 InputBinding 파생 클래스입니다. 설명 부분을 참조하세요.

iCommandImplementation
개체 요소 구문을 지원하는 의 ICommand 개체 구현입니다(공용 매개 변수가 없는 생성자가 있습니다).

적용 대상

추가 정보