MouseEventArgs Class


为与鼠标相关且并不具体涉及鼠标按钮或鼠标滚轮的路由事件(如 MouseMove)提供数据。Provides 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. 这些路由事件转发前面列出的附加事件,使其在 WPFWPF的常规元素模型中更易于访问。These 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 属性以外,MouseEventHandler 实现中可能使用的 MouseEventArgs 的最有趣的属性是公开当前按钮状态(如 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 特别有用,因为你可以对其进行检查 CapturedMouseDevice 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.

(Inherited from InputEventArgs)

获取或设置一个值,该值指示针对路由事件(在其经过路由时)的事件处理的当前状态。Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

(Inherited from 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.

(Inherited from RoutedEventArgs)

获取鼠标右键的当前状态。Gets the current state of the right mouse button.


获取或设置与此 RoutedEventArgs 实例关联的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

(Inherited from RoutedEventArgs)

获取或设置对引发事件的对象的引用。Gets or sets a reference to the object that raised the event.

(Inherited from RoutedEventArgs)

获取与此事件关联的触笔设备。Gets the stylus device associated with this event.


获取此事件发生时的时间。Gets the time when this event occurred.

(Inherited from 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.

(Inherited from Object)

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)

返回相对于指定元素的鼠标指针位置。Returns the position of the mouse pointer relative to the specified element.


获取当前实例的 TypeGets the Type of the current instance.

(Inherited from 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.

(Inherited from 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.

(Inherited from RoutedEventArgs)

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also