MouseEventArgs 類別


提供滑鼠相關路由事件的資料,這些事件並不特別涉及滑鼠按鈕或滑鼠滾輪,例如 MouseMoveProvides data for mouse related routed events that do not specifically involve mouse buttons or the mouse wheel, for example MouseMove.

public ref class MouseEventArgs : System::Windows::Input::InputEventArgs
public class MouseEventArgs : System.Windows.Input.InputEventArgs
type MouseEventArgs = class
    inherit InputEventArgs
Public Class MouseEventArgs
Inherits InputEventArgs


這個事件資料類別會與下列附加事件搭配使用。This event data class is used with the following attached events.

這個事件資料類別會與下列路由事件搭配使用。This event data class is used with the following routed events. 這些路由事件會轉送先前列出的附加事件,讓中的一般元素模型更容易存取 WPFWPFThese routed events forward the previously listed attached events to make them more accessible to the general element model in WPFWPF.

附加事件和基底元素路由事件會共用其事件資料,而路由事件的反升和通道版本也會共用事件資料。The attached events and the base element routed events share their event data, and the bubbling and tunneling versions of the routed events also share event data. 這可能會影響事件在移動事件路由時的已處理特性。This can affect the handled characteristics of the event as it travels the event route. 如需詳細資訊,請參閱 輸入總覽For details, see Input Overview.

除了與 RoutedEventArgs 所有路由事件相關的屬性之外, MouseEventArgs 您可能在執行中使用的最有趣屬性, MouseEventHandler 是公開目前按鈕狀態 (的幾個屬性,例如 LeftButton) 和 MouseDevice) 。Other than the RoutedEventArgs properties that are relevant for all routed events, the most interesting properties of MouseEventArgs that you might use in a MouseEventHandler implementation are several properties that expose the current button state (such as LeftButton) and MouseDevice). MouseDevice 特別有用,因為您可以 Captured 對其進行檢查。MouseDevice is useful particularly because you can check Captured on it.

請注意,特別處理滑鼠按鍵事件的事件會使用不同的事件資料類別 MouseButtonEventArgsNote that events that specifically deal with mouse button events use a different event data class, MouseButtonEventArgs. 當您正在處理非按鈕事件時,可以在上使用滑鼠按鍵屬性, MouseEventArgs 以防有包含按鈕的輸入模式或互動。The mouse button properties are available on MouseEventArgs in case there are input modes or interactions that involve the buttons even if you are handling a non-button event.

Mouse類別會提供其他屬性和方法來判斷滑鼠的狀態。The Mouse class provides additional properties and methods for determining the state of the mouse.


MouseEventArgs(MouseDevice, Int32)

使用所指定 MouseDevice 和時間戳記初始化 MouseEventArgs 類別的新執行個體。Initializes a new instance of the MouseEventArgs class using the specified MouseDevice and timestamp.

MouseEventArgs(MouseDevice, Int32, StylusDevice)

使用指定的 MouseEventArgs、時間戳記和 MouseDevice,初始化 StylusDevice 類別的新執行個體。Initializes a new instance of the MouseEventArgs class using the specified MouseDevice, timestamp, and StylusDevice.



取得初始化這個事件的輸入裝置。Gets the input device that initiated this event.

(繼承來源 InputEventArgs)

取得或設定值,這個值表示路由事件在傳送路由時之事件處理的目前狀態。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

(繼承來源 RoutedEventArgs)

取得滑鼠左鍵的目前狀態。Gets the current state of the left mouse button.


取得滑鼠中鍵的目前狀態。Gets the current state of the middle mouse button.


取得與這個事件相關聯的滑鼠裝置。Gets the mouse device associated with this event.


在父類別進行任何可能的 Source 調整之前,取得純點擊測試所判定的原始報告來源。Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.

(繼承來源 RoutedEventArgs)

取得滑鼠右鍵的目前狀態。Gets the current state of the right mouse button.


取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(繼承來源 RoutedEventArgs)

取得或設定引發事件之物件的參考。Gets or sets a reference to the object that raised the event.

(繼承來源 RoutedEventArgs)

取得與這個事件相關聯的手寫筆裝置。Gets the stylus device associated with this event.


取得這個事件發生的時間。Gets the time when this event occurred.

(繼承來源 InputEventArgs)

取得第一個延伸的滑鼠按鍵的目前狀態。Gets the current state of the first extended mouse button.


取得第二個延伸的滑鼠按鍵的目前狀態。Gets the state of the second extended mouse button.



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

(繼承來源 Object)

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)

傳回滑鼠指標相對於指定之項目的位置。Returns the position of the mouse pointer relative to the specified element.


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

(繼承來源 Object)
InvokeEventHandler(Delegate, Object)

以型別專屬的方式叫用事件處理常式,這樣做能夠提升事件系統的效率。Invokes event handlers in a type-specific way, which can increase event system efficiency.


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

(繼承來源 Object)

在衍生類別中覆寫時,每當執行個體的 Source 屬性值變更,便會提供通知回呼進入點。When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes.

(繼承來源 RoutedEventArgs)

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

(繼承來源 Object)