InputGestureCollection.Add(InputGesture) 方法

定义

将指定的 InputGesture 值添加到此 InputGestureCollection

public:
 int Add(System::Windows::Input::InputGesture ^ inputGesture);
public int Add(System.Windows.Input.InputGesture inputGesture);
member this.Add : System.Windows.Input.InputGesture -> int
Public Function Add (inputGesture As InputGesture) As Integer

参数

inputGesture
InputGesture

要添加到集合中的手势。

返回

0,如果操作成功(请注意,这不是已添加项的索引)。

例外

集合为只读。

手势为 null.

示例

以下示例创建一个 KeyGesture 并将其添加到 InputGestureCollection a RoutedCommand.

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

ApplicationCommands.Open.InputGestures.Add(OpenCmdKeyGesture);
Dim OpenCmdKeyGesture As New KeyGesture(Key.B, ModifierKeys.Control)

ApplicationCommands.Open.InputGestures.Add(OpenCmdKeyGesture)

适用于

另请参阅