MouseEventHandler Delegate

Definition

表示将处理与鼠标相关且不具体涉及鼠标按钮或鼠标滚轮的路由事件(如 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)

Parameters

sender
Object

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

e
MouseEventArgs

事件数据。The event data.

Inheritance
MouseEventHandler

Remarks

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

此委托与以下路由事件一起使用。This delegate 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 的最有趣的属性是公开当前按钮状态的几个属性,如 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 特别有用,因为你可以对其进行检查 CapturedMouseDevice 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.

Extension Methods

GetMethodInfo(Delegate)

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

Applies to

See also