Export (0) Print
Expand All

InputBinding Constructor (ICommand, InputGesture)

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

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

public InputBinding(
	ICommand command,
	InputGesture gesture


Type: System.Windows.Input.ICommand

The command to associate with gesture.

Type: System.Windows.Input.InputGesture

The input gesture to associate with command.


command or gesture is null.

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.

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

KeyGesture HelpCmdKeyGesture = new KeyGesture(Key.H,

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


.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft