System.Windows.Input Namesp ...


.NET Framework Class Library
InputBinding Class

Represents a binding between an InputGesture and a command. The command is potentially a RoutedCommand.

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
Syntax

Visual Basic (Declaration)
Public Class InputBinding _
    Inherits DependencyObject _
    Implements ICommandSource
Visual Basic (Usage)
Dim instance As InputBinding
C#
public class InputBinding : DependencyObject, 
    ICommandSource
Visual C++
public ref class InputBinding : public DependencyObject, 
    ICommandSource
JScript
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.

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.

Examples

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.

XAML
<Window.InputBindings>
  <KeyBinding Key="B"
              Modifiers="Control" 
              Command="ApplicationCommands.Open" />
</Window.InputBindings>
C#
KeyGesture OpenKeyGesture = new KeyGesture(
    Key.B,
    ModifierKeys.Control);

KeyBinding OpenCmdKeybinding = new KeyBinding(
    ApplicationCommands.Open,
    OpenKeyGesture);

this.InputBindings.Add(OpenCmdKeybinding);
Inheritance Hierarchy

System..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows.Input..::.InputBinding
        System.Windows.Input..::.KeyBinding
        System.Windows.Input..::.MouseBinding
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

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.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

Tags :


Page view tracker