InputBinding Class
Represents a binding between an InputGesture and a command. The command is potentially a RoutedCommand.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
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.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Input.InputBinding
System.Windows.Input.KeyBinding
System.Windows.Input.MouseBinding
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.