Namespace:
System.Windows.Input
Assembly:
PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Visual Basic (Declaration)
Public Class InputBinding _
Inherits DependencyObject _
Implements ICommandSource
Dim instance As InputBinding
public class InputBinding : DependencyObject,
ICommandSource
public ref class InputBinding : public DependencyObject,
ICommandSource
public class InputBinding extends DependencyObject implements ICommandSource
XAML Object Element Usage
<inputBindingDerivedClass…/>
XAML Values
- inputBindingDerivedClass
A derived class of InputBinding that supports object element syntax, such as KeyBinding or MouseBinding. See Remarks.
When the InputGesture associated with a InputBinding is performed, the ICommand associated with the InputBinding is executed.
An InputBinding can be defined on a specific object or at the class level by registering a RegisterClassInputBinding with the CommandManager.
The InputBinding class itself does not support XAML usage, because it does not expose a public default constructor (there is a default constructor, but it is protected). However, derived classes can expose a public constructor and thus can set properties on the derived class that are inherited from InputBinding with a XAML usage. Two existing InputBinding derived classes that can be instantiated in XAML and can set properties in XAML are KeyBinding and MouseBinding. The typical property in WPF programming that is set in XAML and takes one or more InputBinding objects as values is the UIElement..::.InputBindings property.
The following example shows how to use a KeyBinding to bind a KeyGesture to the Open command. When the key gesture is performed, the Open command is invoked.
<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);
System..::.Object
System.Windows.Threading..::.DispatcherObject
System.Windows..::.DependencyObject
System.Windows.Input..::.InputBinding
System.Windows.Input..::.KeyBinding
System.Windows.Input..::.MouseBinding
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0
Reference
Other Resources