MouseEventHandler 委托


表示将处理与鼠标相关且不具体涉及鼠标按钮或鼠标滚轮的路由事件(如 MouseMove)的方法。Represents the method that will handle mouse related routed events that do not specifically involve mouse buttons or the mouse wheel; for example, MouseMove.

public delegate void MouseEventHandler(System::Object ^ sender, MouseEventArgs ^ e);
public delegate void MouseEventHandler(object sender, MouseEventArgs e);
type MouseEventHandler = delegate of obj * MouseEventArgs -> unit
Public Delegate Sub MouseEventHandler(sender As Object, e As MouseEventArgs)



事件处理程序所附加到的对象。The object where the event handler is attached.


事件数据。The event data.


此委托与以下附加事件一起使用:This delegate is used with the following attached events:

此委托与以下路由事件一起使用。This delegate is used with the following routed events. 这些路由事件转发前面列出的附加事件,使其更易于访问 WPF 中的常规元素模型。These routed events forward the previously listed attached events to make them more accessible to the general element model in WPF.

附加事件和基本元素路由事件共享其事件数据,路由事件的冒泡和隧道版本也共享事件数据。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 也是一些公开当前按钮状态的属性,例如 LeftButtonMouseDeviceOther 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.

请注意,专门处理鼠标按钮事件的事件使用不同的委托 MouseButtonEventHandlerNote that events that specifically deal with mouse button events use a different delegate, MouseButtonEventHandler. 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.



获取指示指定委托表示的方法的对象。Gets an object that represents the method represented by the specified delegate.