InputBindingCollection.Add(InputBinding) Método

Definición

Agrega el objeto de InputBinding especificado a esta clase 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

Parámetros

inputBinding
InputBinding

Enlace que se va a agregar a la colección.

Devoluciones

Siempre devuelve 0. Esto se desvía de la implementación de IList estándar para Add, que debe devolver el índice en el que el nuevo elemento se agregó a la colección.

Excepciones

inputBinding es null.

Ejemplos

En el ejemplo siguiente se crea un KeyGesture objeto y se asocia a .KeyBinding KeyBinding se agrega a InputBindingCollection en un Windowobjeto .

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

En el ejemplo XAML no se usa Addliteralmente , pero Add se llama implícitamente mediante la compatibilidad de procesamiento XAML para colecciones. Para obtener más información sobre XAML y colecciones, consulta Información general sobre XAML (WPF).

Se aplica a

Consulte también