ContentElement.OnMouseLeftButtonDown(MouseButtonEventArgs) ContentElement.OnMouseLeftButtonDown(MouseButtonEventArgs) ContentElement.OnMouseLeftButtonDown(MouseButtonEventArgs) ContentElement.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.

protected public:
 virtual void OnMouseLeftButtonDown(System::Windows::Input::MouseButtonEventArgs ^ e);
protected internal 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 Friend Overridable Sub OnMouseLeftButtonDown (e As MouseButtonEventArgs)

參數

e
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是以反升路由的基礎事件, 而且每ContentElement個事件路由都會使用相同的處理來引發直接路由事件MouseLeftButtonDownMouse.MouseDown is the underlying event that is bubble routed, and each ContentElement 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.

ContentElement一般滑鼠事件處理的預設執行會Mouse.MouseDown接聽並將它轉換為適當的本機事件。The default implementation for general mouse event handling in ContentElement 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. 您無法藉ContentElement由覆寫OnMouseLeftButtonDown來變更的滑鼠處理行為。You cannot change the mouse handling behavior of ContentElement 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. 無法呼叫 base 會停用該滑鼠事件在也預期OnMouseLeftButtonDown會叫用之祖系類別上的預設輸入處理。Failing 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.

適用於