InputBindingCollection.Add(InputBinding) Metoda

Definice

Přidá do tohoto InputBindingCollectionparametru zadaný InputBinding parametr .

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

Parametry

inputBinding
InputBinding

Vazba, která se má přidat do kolekce.

Návraty

Vždy vrátí hodnotu 0. Tím se liší od standardní IList implementace Add, která by měla vrátit index, ve kterém byla nová položka přidána do kolekce.

Výjimky

inputBinding je null.

Příklady

Následující příklad vytvoří KeyGesture a přidruží ho k .KeyBinding Přidá se KeyBinding do InputBindingCollection pole 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)

Příklad XAML doslova nepoužívá Add, ale Add je volána implicitně pomocí podpory zpracování XAML pro kolekce. Podrobnosti o XAML a kolekcích najdete v tématu Přehled XAML (WPF).

Platí pro

Viz také