InputBindingCollection.Add(InputBinding) Méthode
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.
Ajoute le spécifié InputBinding à ce InputBindingCollection.
public:
int Add(System::Windows::Input::InputBinding ^ inputBinding);
public int Add(System.Windows.Input.InputBinding inputBinding);
member this.Add : System.Windows.Input.InputBinding -> int
Public Function Add (inputBinding As InputBinding) As Integer
Paramètres
- inputBinding
- InputBinding
Liaison à ajouter à la collection.
Retours
Retourne toujours 0. Cela s’écarte de l’implémentation standard IList pour Add, qui doit retourner l’index où le nouvel élément a été ajouté à la collection.
Exceptions
inputBinding a la valeur null.
Exemples
L’exemple suivant crée et KeyGesture l’associe à un KeyBinding. Il KeyBinding est ajouté à l’on InputBindingCollection a Window.
<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)
L’exemple XAML n’utilise Addpas littéralement , mais Add est appelé implicitement par la prise en charge du traitement XAML pour les collections. Pour plus d’informations sur XAML et les collections, consultez vue d’ensemble du code XAML (WPF).