ContentElement.MouseLeftButtonDown ContentElement.MouseLeftButtonDown ContentElement.MouseLeftButtonDown ContentElement.MouseLeftButtonDown Event


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

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



雖然這路由事件概觀似乎會遵循事件反昇路由項目樹狀結構中,它實際上是直接路由的事件的引發並由每個項目樹狀結構中沿著 reraised ContentElementAlthough this Routed Events Overview seems to follow a bubbling route through an element tree, it actually is a direct routed event that is raised and reraised along the element tree by each ContentElement.

此事件會報告滑鼠按鈕的細節有基礎的多個相關事件的其中一個Mouse.MouseDown事件,這是附加的事件處理的事件路由的每個項目。This event is one of several related events that report the mouse-button specifics of an underlying Mouse.MouseDown event, which is an attached event that is processed by each element along an event route.

此事件的引數公開 (expose) 的引數的基礎Mouse.MouseDown事件。The arguments of this event expose the arguments of the underlying Mouse.MouseDown 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.

就概念而言,將此事件 (和其他的滑鼠按鍵事件,對於ContentElement) 是滑鼠 「 服務 」 (使用所提供的服務定義Mouse類別)。Conceptually, think of this event (and other mouse-button events on ContentElement) 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. 針對更進階的案例,例如檢查狀態的標準按鈕,您可能需要使用APIAPIsMouse類別,而這些非上ContentElementFor more advanced scenarios, such as checking for states of non-standard buttons, you might need to use the APIAPIs on the Mouse class rather than those on ContentElement.


少數ContentElement衍生的類別具有類似控制項的行為,例如, Hyperlink,可能具有固有處理按鈕的滑鼠事件的類別。A few ContentElement derived classes that have control-like behavior, for example, Hyperlink, might have inherent class handling for mouse button events. 滑鼠左的按鈕向下事件是最可能的事件,讓控制項中的類別處理。The left mouse button down event is the most likely event to have class handling in a control. 類別處理,通常會將標示基礎Mouse為已處理的類別事件。The class handling often marks the underlying Mouse class event as handled. 一旦被標示為已處理,通常無法引發另一個執行個體處理常式附加至該項目。Once the event is marked handled, other instance handlers that are attached to that element are not ordinarily raised. 也不通常會引發任何其他類別或執行個體處理常式附加至事件反昇方向朝向 UI 樹狀目錄中的根項目。Any other class or instance handlers that are attached to elements in the bubbling direction towards the root in the UI tree are also not ordinarily raised.

您可以解決的問題,在上述的重要概述,並仍收到MouseLeftButtonDown滑鼠左的按鈕向下事件已處理就使用任一這些方案的類別衍生類別上的事件:You can resolve the issue that is outlined in the preceding Important and still receive MouseLeftButtonDown events for left mouse button down events on a derived class that has class handling by using either of these solutions:

  • 附加的處理常式PreviewMouseDown未標示為已由控制項所處理的事件。Attach handlers for the PreviewMouseDown event, which is not marked as handled by the controls. 請注意,因為這是預覽事件,路由從根目錄開始,並向下控制項。Notice that because this is a preview event, the route starts at the root and tunnels down to the control.

  • 藉由呼叫可循序註冊控制項上的處理常式AddHandler,然後選擇 [簽章] 選項,可讓處理常式來接聽事件,即使它們已經標示為已處理路由的事件資料中。Register a handler on the control procedurally by calling AddHandler and choosing the signature option that enables handlers to listen for events even if they are already marked as handled in the routed event data.

路由事件資訊Routed Event Information

識別項欄位Identifier field MouseLeftButtonDownEvent
路由策略Routing strategy 直接Direct
Delegate - 委派Delegate MouseButtonEventHandler