语言

InputBinding 构造函数

定义

初始化 InputBinding 类的新实例。

重载

名称 说明
InputBinding()

为派生自 InputBinding的类提供基初始化。

InputBinding(ICommand, InputGesture)

使用指定的命令和输入手势初始化类的新实例 InputBinding 。

InputBinding()

为派生自 InputBinding的类提供基初始化。

protected:
 InputBinding();
protected InputBinding();
Protected Sub New ()

注解

InputBinding 在技术上不是抽象类,但无参数构造函数是故意保护的访问。 这会影响为 XAML 创建 InputBinding “抽象”类。 WPF中有一些现有属性,这些属性的 XAML 用法需要InputBinding类型的对象,但不能在 XAML 中指定 InputBinding 实例。 相反,你可以将设备特定的 InputBinding 派生类之一指定为值,例如 KeyBinding 或 MouseBinding。

继承者说明

如果实现支持 XAML 用法的自定义 InputBinding ,请使用此构造函数进行基本初始化。

适用于

InputBinding(ICommand, InputGesture)

使用指定的命令和输入手势初始化类的新实例 InputBinding 。

public:
 InputBinding(System::Windows::Input::ICommand ^ command, System::Windows::Input::InputGesture ^ gesture);
[System.Security.SecurityCritical]
public InputBinding(System.Windows.Input.ICommand command, System.Windows.Input.InputGesture gesture);
public InputBinding(System.Windows.Input.ICommand command, System.Windows.Input.InputGesture gesture);
[<System.Security.SecurityCritical>]
new System.Windows.Input.InputBinding : System.Windows.Input.ICommand * System.Windows.Input.InputGesture -> System.Windows.Input.InputBinding
new System.Windows.Input.InputBinding : System.Windows.Input.ICommand * System.Windows.Input.InputGesture -> System.Windows.Input.InputBinding
Public Sub New (command As ICommand, gesture As InputGesture)

参数

command
ICommand

要与之 gesture关联的命令。

gesture
InputGesture

要与之 command关联的输入手势。

特性

例外

command 或 gesture 为 null.

示例

以下示例演示如何使用此构造函数将 a 与 a KeyGestureRoutedCommand.

KeyGesture HelpCmdKeyGesture = new KeyGesture(Key.H,
    ModifierKeys.Alt);

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

this.InputBindings.Add(inputBinding);
Dim HelpCmdKeyGesture As New KeyGesture(Key.H, ModifierKeys.Alt)

Dim inputBinding As InputBinding
inputBinding = New InputBinding(ApplicationCommands.Help, HelpCmdKeyGesture)

Me.InputBindings.Add(inputBinding)

注解

如果你是使用现有输入绑定类的软件开发人员,则通常不会使用此构造函数,即使你正在定义自定义命令。 而是使用派生类的构造函数(KeyBinding 和 MouseBinding),或者将此构造函数用作自定义类的基本实例化。 尽管该 InputBinding 类原则上支持不同的输入设备,但实际上必须选择输入绑定将表示的设备。 只能在输入绑定上设置一个 Gesture 值,并且手势特定于设备。

适用于