InputBinding Constructors

Definition

Initializes a new instance of the InputBinding class.

Overloads

InputBinding()

Provides base initialization for classes derived from InputBinding.

InputBinding(ICommand, InputGesture)

Initializes a new instance of the InputBinding class with the specified command and input gesture.

InputBinding()

Provides base initialization for classes derived from InputBinding.

protected:
 InputBinding();
protected InputBinding ();
Protected Sub New ()

Remarks

InputBinding is not technically an abstract class, but the parameterless constructor is deliberately protected access. This has the effect of making InputBinding an "abstract" class for XAML. There are existing properties in WPF that have XAML usages that expect objects of type InputBinding, but you cannot specify an InputBinding instance in XAML. Instead, you can specify one of the device-specific InputBinding derived classes as values, for instance KeyBinding or MouseBinding.

Notes to Inheritors

If you implement a custom InputBinding that supports a XAML usage, use this constructor for base initialization.

Applies to

InputBinding(ICommand, InputGesture)

Initializes a new instance of the InputBinding class with the specified command and input gesture.

public:
 InputBinding(System::Windows::Input::ICommand ^ command, System::Windows::Input::InputGesture ^ gesture);
[System.Security.SecurityCritical]
public InputBinding (System.Windows.Input.ICommand command, System.Windows.Input.InputGesture gesture);
public InputBinding (System.Windows.Input.ICommand command, System.Windows.Input.InputGesture gesture);
[<System.Security.SecurityCritical>]
new System.Windows.Input.InputBinding : System.Windows.Input.ICommand * System.Windows.Input.InputGesture -> System.Windows.Input.InputBinding
new System.Windows.Input.InputBinding : System.Windows.Input.ICommand * System.Windows.Input.InputGesture -> System.Windows.Input.InputBinding
Public Sub New (command As ICommand, gesture As InputGesture)

Parameters

command
ICommand

The command to associate with gesture.

gesture
InputGesture

The input gesture to associate with command.

Attributes

Exceptions

command or gesture is null.

Examples

The following example shows how to use this constructor to associate a KeyGesture with a RoutedCommand.

KeyGesture HelpCmdKeyGesture = new KeyGesture(Key.H,
    ModifierKeys.Alt);

InputBinding inputBinding;
inputBinding = new InputBinding(ApplicationCommands.Help,
    HelpCmdKeyGesture);

this.InputBindings.Add(inputBinding);
Dim HelpCmdKeyGesture As New KeyGesture(Key.H, ModifierKeys.Alt)

Dim inputBinding As InputBinding
inputBinding = New InputBinding(ApplicationCommands.Help, HelpCmdKeyGesture)

Me.InputBindings.Add(inputBinding)

Remarks

If you are a software developer using existing input binding classes, you generally will not use this constructor, even if you are defining custom commands. Instead, you will either use constructors of derived classes (KeyBinding and MouseBinding), or you will use this constructor as the base instantiation of a custom class. Although the InputBinding class supports different input devices in principle, in practice you must choose which device the input binding will represent. You only can set only one Gesture value on the input binding, and gestures are device-specific.

Applies to