InputBindingCollection.Add(InputBinding) Metod

Definition

Lägger till den angivna InputBinding i den här 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

Parametrar

inputBinding
InputBinding

Bindningen som ska läggas till i samlingen.

Returer

Returnerar alltid 0. Detta avviker från standardimplementeringen IList för Add, som ska returnera indexet där det nya objektet lades till i samlingen.

Undantag

inputBinding är null.

Exempel

I följande exempel skapas en KeyGesture och associeras med en KeyBinding. KeyBinding Läggs till i på InputBindingCollection en 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)

XAML-exemplet använder Addinte bokstavligen , men Add anropas implicit av XAML-bearbetningsstödet för samlingar. Mer information om XAML och samlingar finns i XAML Overview (WPF).

Gäller för

Se även