UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs) UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs) UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs) UIElement.OnMouseLeftButtonDown(MouseButtonEventArgs) Method


當這個項目上引發未處理的 MouseLeftButtonDown 路由事件時叫用。Invoked when an unhandled MouseLeftButtonDown routed event is raised on this element. 實作這個方法可為此事件加入類別處理。Implement this method to add class handling for this event.

 virtual void OnMouseLeftButtonDown(System::Windows::Input::MouseButtonEventArgs ^ e);
protected virtual void OnMouseLeftButtonDown (System.Windows.Input.MouseButtonEventArgs e);
abstract member OnMouseLeftButtonDown : System.Windows.Input.MouseButtonEventArgs -> unit
override this.OnMouseLeftButtonDown : System.Windows.Input.MouseButtonEventArgs -> unit
Protected Overridable Sub OnMouseLeftButtonDown (e As MouseButtonEventArgs)


MouseButtonEventArgs MouseButtonEventArgs MouseButtonEventArgs MouseButtonEventArgs

包含事件資料的 MouseButtonEventArgsThe MouseButtonEventArgs that contains the event data. 事件資料會報告滑鼠左鍵已按下。The event data reports that the left mouse button was pressed.


MouseLeftButtonDown似乎事件反昇路由事件,但實際上會以間接方式傳送。The MouseLeftButtonDown event appears to travel a bubbling route but actually travels in an indirect way. Mouse.MouseDown 是路由傳送,泡泡圖的基礎事件和每個UIElement沿著事件路由會使用相同的處理結果來引發直接路由的事件MouseLeftButtonDownMouse.MouseDown is the underlying event that is bubble routed, and each UIElement along the event route uses identical handling to raise the direct routed event MouseLeftButtonDown. 雖然您可以將標記MouseLeftButtonDown事件為已處理的這個項目的用途,已處理的狀態不保存事件路由中的其他項目。Although you can mark the MouseLeftButtonDown event as handled for purposes of this element, the handled state does not perpetuate to other elements along the event route. 不過,您可能想要將事件標示為已處理,以避免一般的執行個體處理常式 (未指定的指handledEventsToo) 叫用。However, you might want to mark the event as handled in order to prevent general instance handlers (those that did not specify handledEventsToo) from being invoked.

一般的滑鼠事件處理中的預設實作UIElement接聽Mouse.MouseDown並將它轉換成適當的本機事件。The default implementation for general mouse event handling in UIElement listens for Mouse.MouseDown and converts it to an appropriate local event. 如果您想要覆寫此邏輯,您必須建立衍生的類別。If you want to override this logic, you must create a derived class. 在衍生類別的靜態建構函式中註冊替代的類別處理常式Mouse.MouseDownIn the static constructor of your derived class, register an alternative class handler for Mouse.MouseDown. 您無法變更處理行為的滑鼠UIElement藉由覆寫OnMouseLeftButtonDownYou cannot change the mouse handling behavior of UIElement by overriding OnMouseLeftButtonDown.

或者,您可以覆寫這個方法以變更處理特定的滑鼠狀態的事件。Alternatively, you can override this method in order to change event handling for a specific mouse state. 不論您選擇呼叫的基底實作,取決於您的案例。Whether you choose to call the base implementation depends on your scenario. 無法呼叫基底會停用該也預期要叫用的上階類別上的滑鼠事件的預設輸入的處理OnMouseLeftButtonDownFailing to call base disables default input handling for that mouse event on ancestor classes that also expect to invoke OnMouseLeftButtonDown. 例如,您可以從衍生Button,並覆寫OnMouseLeftButtonDown在您的衍生類別,而不需要呼叫基底實作中,不過,這會覆寫停用Click事件。For example, you can derive from Button and override OnMouseLeftButtonDown in your derived class without calling the base implementation; however, this override disables the Click event.