共用方式為


MouseGesture.Matches(Object, InputEventArgs) 方法

定義

判斷 MouseGesture 是否符合與指定之 InputEventArgs 物件相關聯的輸入。

public:
 override bool Matches(System::Object ^ targetElement, System::Windows::Input::InputEventArgs ^ inputEventArgs);
public override bool Matches (object targetElement, System.Windows.Input.InputEventArgs inputEventArgs);
override this.Matches : obj * System.Windows.Input.InputEventArgs -> bool
Public Overrides Function Matches (targetElement As Object, inputEventArgs As InputEventArgs) As Boolean

參數

targetElement
Object

目標。

inputEventArgs
InputEventArgs

要和這個筆勢比較的輸入事件資料。

傳回

如果事件資料符合這個 MouseGesture,則為 true,否則為 false

範例

下列範例示範如何測試 是否符合 MouseGesture 與 實例 InputEventArgs相關聯的輸入。 MouseDown事件處理程式會使用 Matches 方法來比較事件資料與 MouseGesture

private void OnMouseDown(object sender, MouseEventArgs e)
{
    MouseGesture mouseGesture = new MouseGesture(MouseAction.MiddleClick,ModifierKeys.Control);

    if (mouseGesture.Matches(null, e))
    {
        MessageBox.Show("Trapped Mouse Gesture");
    }
}
Private Overloads Sub OnMouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim mouseGesture As New MouseGesture(MouseAction.MiddleClick,ModifierKeys.Control)

    If mouseGesture.Matches(Nothing, e) Then
        MessageBox.Show("Trapped Mouse Gesture")
    End If
End Sub

適用於