Command Property
Collapse the table of content
Expand the table of content

InputBinding.Command Property


Gets or sets the ICommand associated with this input binding.

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

[TypeConverterAttribute("System.Windows.Input.CommandConverter, PresentationFramework, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public ICommand Command { get; set; }

Property Value

Type: System.Windows.Input.ICommand

The associated command.

Exception Condition

The Command value is null.

The InputBinding class does not support XAML usage because it does not expose a public default constructor (it has a default constructor, but it is protected). However, derived classes can expose a public constructor and therefore, can use properties that are inherited from InputBinding. Two existing InputBinding derived classes that can be instantiated in XAML and can set properties with XAML usages are KeyBinding and MouseBinding.

ICommand references a type converter that enables certain preexisting ICommand implementations to specify values in the form of a string. This type conversion behavior sets the attribute value form of this property. You can also bind the Command, CommandParameter, and CommandTarget properties to an ICommand that is defined on an object. This enables you to define a custom command and associate it with user input. For more information, see the second example in InputBinding.

<inputBindingDerivedClass Command="ICommand"/>



A derived class of InputBinding that supports object element syntax, such as KeyBinding or MouseBinding. See Remarks.


An object implementation of ICommand that supports object element syntax (has a public default constructor).

Legacy Code Example

The following example shows how to use a KeyBinding to bind a KeyGesture to the ApplicationCommands.Open command. When the key gesture is performed, the Open command is invoked.

Code snippet is not found. Confirm that the code snippet name 'commandingoverviewsnippets' is correct.Code snippet is not found. Confirm that the code snippet name 'commandingoverviewsnippets' is correct.

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft