InputBinding.Command Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit le ICommand associé à 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
Command a la valeur null
.
Exemples
L’exemple suivant montre comment utiliser un KeyBinding pour lier un KeyGesture à la ApplicationCommands.Open commande . Lorsque le mouvement de la clé est effectué, la commande Ouvrir 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 InputBinding classe ne prend pas en charge l’utilisation de XAML, car elle n’expose pas de constructeur public sans paramètre (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, peuvent 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 Commandpropriétés , CommandParameteret CommandTarget à un ICommand qui est défini sur un objet . Cela vous permet de définir une commande personnalisée et de l’associer à une entrée utilisateur. Pour plus d’informations, consultez le deuxième exemple dans InputBinding.
Utilisation d'attributs XAML
<inputBindingDerivedClass
Command
="ICommand"/>
Utilisation des éléments de propriété XAML
<inputBindingDerivedClass>
<inputBindingDerivedClass.Command>
<iCommandImplementation/>
</inputBindingDerivedClass.Command>
</inputBindingDerivedClass>
Valeurs XAML
inputBindingDerivedClass
Classe dérivée de qui prend en charge la syntaxe d’élément InputBinding d’objet, telle que KeyBinding ou MouseBinding. Consultez la section Notes.
iCommandImplementation
Implémentation d’objet de ICommand qui prend en charge la syntaxe des éléments d’objet (a un constructeur public sans paramètre).
S’applique à
Voir aussi
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour