InputBinding.Command Propriété

Définition

Obtient ou définit l’associé ICommand à cette liaison d’entrée.

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

Valeur de propriété

Commande associée.

Attributs

Exceptions

La Command valeur est null.

Exemples

L’exemple suivant montre comment utiliser une KeyBinding liaison à KeyGesture la ApplicationCommands.Open commande. Lorsque le mouvement de clé est effectué, la commande Open est appelée.

<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)

Remarques

La classe ne prend pas en charge l’utilisation InputBinding XAML, car elle n’expose pas de constructeur sans paramètre public (elle a un constructeur sans paramètre, mais elle est protégée). Toutefois, les classes dérivées peuvent exposer un constructeur public et, par conséquent, utiliser des propriétés héritées de InputBinding. Deux classes dérivées existantes InputBinding qui peuvent être instanciées en XAML et qui peuvent définir des propriétés avec des utilisations XAML sont KeyBinding et MouseBinding.

ICommand fait référence à un convertisseur de type qui permet à certaines implémentations préexistantes ICommand de spécifier des valeurs sous la forme d’une chaîne. Ce comportement de conversion de type définit la forme de valeur d’attribut de cette propriété. Vous pouvez également lier les propriétés et CommandParameterCommandTarget les Commandpropriétés à un ICommand objet défini sur un objet. Cela vous permet de définir une commande personnalisée et de l’associer à l’entrée utilisateur. Pour plus d’informations, consultez le deuxième exemple dans InputBinding.

Utilisation des attributs XAML

< inputBindingDerivedClass Command="""ICommand/>

Utilisation de l’élément de propriété XAML

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

Valeurs XAML

inputBindingDerivedClass Classe dérivée de celle-ci prend en charge la syntaxe d’élément InputBinding objet, telle que KeyBinding ou MouseBinding. Voir les remarques.

iCommandImplementation Implémentation d’objet de ce qui prend en charge la syntaxe d’élément ICommand d’objet (a un constructeur sans paramètre public).

S’applique à

Voir aussi