MouseGesture 類別

定義

定義可以用來叫用命令的滑鼠輸入筆勢。Defines a mouse input gesture that can be used to invoke a command.

public ref class MouseGesture : System::Windows::Input::InputGesture
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.MouseGestureConverter))]
public class MouseGesture : System.Windows.Input.InputGesture
type MouseGesture = class
    inherit InputGesture
Public Class MouseGesture
Inherits InputGesture
繼承
MouseGesture
屬性

範例

下列範例會示範如何建立MouseGesture , 並透過MouseBinding將它與RoutedCommand建立關聯。The following example shows to create a MouseGesture and associate it with a RoutedCommand through a MouseBinding. 按下滑鼠滾輪時Control Open , 按一下按鍵時, 就會叫用。When the mouse wheel is clicked while the Control key is pressed, the Open is invoked.

<MouseBinding Gesture="Control+WheelClick"
              Command="ApplicationCommands.Open" />
MouseGesture OpenCmdMouseGesture = new MouseGesture();
OpenCmdMouseGesture.MouseAction = MouseAction.WheelClick;
OpenCmdMouseGesture.Modifiers = ModifierKeys.Control;

MouseBinding OpenCmdMouseBinding = new MouseBinding();
OpenCmdMouseBinding.Gesture = OpenCmdMouseGesture;
OpenCmdMouseBinding.Command = ApplicationCommands.Open;

this.InputBindings.Add(OpenCmdMouseBinding);
Dim OpenCmdMouseGesture As New MouseGesture()
OpenCmdMouseGesture.MouseAction = MouseAction.WheelClick
OpenCmdMouseGesture.Modifiers = ModifierKeys.Control

Dim OpenCmdMouseBinding As New MouseBinding()
OpenCmdMouseBinding.Gesture = OpenCmdMouseGesture
OpenCmdMouseBinding.Command = ApplicationCommands.Open

Me.InputBindings.Add(OpenCmdMouseBinding)

備註

與不同KeyGesture的是MouseAction , 不需要將與ModifierKeys配對成有效MouseGesture的。Unlike a KeyGesture, a MouseAction does not have to be paired with ModifierKeys to be a valid MouseGesture.

可以MouseGesture透過系結RoutedCommand至 (或MouseBinding其他ICommand的執行), 以便在MouseGesture發生時叫用命令。A MouseGesture can be bound to a RoutedCommand (or other ICommand implementations) through a MouseBinding so that the command is invoked when the MouseGesture occurs.

針對MouseGesture XAMLXAML Gesture屬性使用方式, 通常在中設定的屬性是, 而筆勢可以同時代表滑鼠動作和一個或多個輔助按鍵。 XAMLXAMLFor MouseGesture XAMLXAML attribute usages, the property that is generally set in XAMLXAML is Gesture, in cases where the gesture can represent both a mouse action and one or more modifier key. 您也可以將Gesture屬性設定為只是一個滑鼠動作。You can also set the Gesture property to be just a mouse action. 一般來說, 即使您未指定修飾詞, 也建議Gesture您只XAMLXAML使用來自的屬性MouseAction, 而不是設定。In general, it is recommended that you use only the Gesture attribute from XAMLXAML, rather than setting MouseAction, even if you do not specify modifiers. 這可避免發生不明確的情況, 提供最有效率的語法, 並提供最直接的序列化標記法。This will avoid ambiguity, provides the most streamlined syntax, and provides the most straightforward representation for serialization.

MouseGesture物件元素的使用方式是可行的, 但不常見, 因為Gesture您通常MouseBinding可以在不使用屬性專案語法的情況下, 設定內嵌的屬性。 XAMLXAMLMouseGesture XAMLXAML object element usages are possible but uncommon, because you can ordinarily set the Gesture property of MouseBinding inline without the use of property element syntax.

XAML Attribute UsageXAML Attribute Usage

<object property="mouseAction"/>  
- or -  
<object property="oneOrMoreModifierKeys+mouseAction"/>  

XAML 值XAML Values

mouseAction
MouseAction

單一滑鼠動作。A single mouse action.

oneOrMoreModifierKeys
ModifierKeys列舉定義的一個或多個輔助按鍵。One or more modifier keys, defined by the ModifierKeys enumeration. 如果提供了一個以上的輔助按鍵, 則每個輔助按鍵都會以 "+" 字元分隔。If more than one modifier key is provided, each modifier key is delimited with a "+" character.

建構函式

MouseGesture()

初始化 MouseGesture 類別的新執行個體。Initializes a new instance of the MouseGesture class.

MouseGesture(MouseAction)

使用指定的 MouseGesture,初始化 MouseAction 類別的新執行個體。Initializes a new instance of the MouseGesture class using the specified MouseAction.

MouseGesture(MouseAction, ModifierKeys)

使用指定的 MouseGestureMouseAction,初始化 ModifierKeys 類別的新執行個體。Initializes a new instance of the MouseGesture class using the specified MouseAction and ModifierKeys.

屬性

Modifiers

取得或設定與這個 MouseGesture 相關聯的輔助按鍵。Gets or sets the modifier keys associated with this MouseGesture.

MouseAction

取得或設定與這個筆勢相關聯的 MouseActionGets or sets the MouseAction associated with this gesture.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
Matches(Object, InputEventArgs)

判斷 MouseGesture 是否符合與指定之 InputEventArgs 物件相關聯的輸入。Determines whether MouseGesture matches the input associated with the specified InputEventArgs object.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱