InputBindingCollection.Add(InputBinding) Método

Definición

Agrega el objeto especificado InputBinding a este InputBindingCollectionobjeto .

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 estándar IList de Add, que debe devolver el índice donde se agregó el nuevo elemento 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 en InputBindingCollection 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)

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

Se aplica a

Consulte también