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. 這些路由事件會轉送先前列出的附加事件,讓中的一般元素模型更容易存取 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 是公開目前按鈕狀態的數個屬性,例如 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.