UIElement.PreviewMouseRightButtonDown 事件


滑鼠指標在此元素上方且按下滑鼠右按鈕時發生。Occurs when the right mouse button is pressed while the mouse pointer is over this element.

 virtual event System::Windows::Input::MouseButtonEventHandler ^ PreviewMouseRightButtonDown;
public event System.Windows.Input.MouseButtonEventHandler PreviewMouseRightButtonDown;
member this.PreviewMouseRightButtonDown : System.Windows.Input.MouseButtonEventHandler 
Public Custom Event PreviewMouseRightButtonDown As MouseButtonEventHandler 





雖然這個 路由事件 似乎是在透過專案樹狀結構的通道路由下進行,但其實是直接路由事件,它會沿著元素樹狀結構逐一引發並 reraised UIElementAlthough this routed event seems to follow a tunneling route through an element tree, it actually is a direct routed event that is raised and reraised along the element tree by each UIElement.

此事件是數個相關事件的其中之一,可報告基礎事件的滑鼠按鍵細節 Mouse.PreviewMouseDown ,也就是每個元素沿著事件路由所處理的附加事件。This event is one of several related events that report the mouse-button specifics of an underlying Mouse.PreviewMouseDown event, which is an attached event that is processed by each element along an event route.

此事件的事件資料會公開基礎事件的事件資料 Mouse.PreviewMouseDownThe event data of this event exposes the event data of the underlying Mouse.PreviewMouseDown event. 如果該事件在事件路由中標示為已處理,則仍然會引發滑鼠按鍵特定事件;不過,您必須明確呼叫來加入滑鼠按鍵特定事件的處理常式 AddHandler ,並使用選項來處理已標示為已處理的事件,以便成為事件的接聽程式。If that event is marked as handled along the event route, the mouse-button specific events are still raised; however, handlers of the mouse-button specific events must be added by explicitly calling AddHandler, with the option to handle events that are already marked as handled, in order to be listeners to the event. 如果您標示 PreviewMouseRightButtonDown 為已處理,則會在 Mouse.PreviewMouseDown 路由中以及所有相關事件上,對所有進一步的接聽程式進行標記處理。If you mark PreviewMouseRightButtonDown handled, you are essentially marking Mouse.PreviewMouseDown handled for all further listeners along the route, and on all related events. 這可能包含類別處理常式產生的事件(例如) PreviewMouseDoubleClickThis possibly includes class-handler generated events such as PreviewMouseDoubleClick.

從概念上來說,您可以將這個事件 (,而) 的其他滑鼠按鍵事件視為 UIElement 滑鼠「服務」 (具有類別) 所提供的服務定義 MouseConceptually, think of this event (and other mouse-button events on UIElement) to be a mouse "service" (with the service definition provided by the Mouse class). 此事件可增加不需要檢查滑鼠按鍵狀態的便利性, (在事件資料中原始滑鼠事件的左邊) 。The event adds the convenience of not needing to check the mouse button states (left-right, up-down) of the original mouse events in the event data. 針對更先進的案例,例如檢查非標準按鈕的狀態,您可能需要使用類別上的 Api, Mouse 而不是上的 api UIElementFor more advanced scenarios, such as checking for states of non-standard buttons, you might need to use the APIs on the Mouse class rather than those on UIElement.

路由事件資訊Routed Event Information

識別碼欄位Identifier field PreviewMouseRightButtonDownEvent
路由策略Routing strategy 直接Direct
代理人Delegate MouseButtonEventHandler