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 並將其新增至 InputGestureCollectionRoutedCommand

<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)

適用於

另請參閱