ContentElement.MouseDown ContentElement.MouseDown ContentElement.MouseDown ContentElement.MouseDown Event


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

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


此事件建立的別名Mouse.MouseDown附加事件,此類別中,以便MouseDown屬於類別的成員清單時ContentElement繼承為基底的項目。This event creates an alias for the Mouse.MouseDown attached event for this class, so that MouseDown is part of the class members list when ContentElement is inherited as a base element. 附加至事件處理常式MouseDown事件會附加至基礎Mouse.MouseDown附加事件,並接收相同的事件資料執行個體。Event handlers that are attached to the MouseDown event are attached to the underlying Mouse.MouseDown attached event and receive the same event data instance.

MouseDown通常就會引發事件一起MouseLeftButtonDownMouseRightButtonDown,對應到其中的兩個標準的滑鼠按鈕按下。The MouseDown event is often raised together with either MouseLeftButtonDown or MouseRightButtonDown, which correspond to a press of one of the two standard mouse buttons. MouseLeftButtonDownMouseRightButtonDown也是路由的事件,但它們是直接路由的事件,並適當按鈕特有的事件引發時Mouse.MouseDown事件到達事件路由中的此項目。MouseLeftButtonDown and MouseRightButtonDown are also routed events, but they are direct routed events, and the appropriate button-specific event is raised when the Mouse.MouseDown event reaches this element along the event route. 請參閱備註MouseLeftButtonDownMouseRightButtonDownSee Remarks for MouseLeftButtonDown or MouseRightButtonDown.


少數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.

您可以解決的問題,在上述的重要概述,並仍收到MouseDown滑鼠左的按鈕向下事件已處理就使用任一這些方案的類別衍生類別上的事件:You can resolve the issue that is outlined in the preceding Important and still receive MouseDown 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 MouseDownEvent
路由策略Routing strategy 事件反昇Bubbling
Delegate - 委派Delegate MouseButtonEventHandler