Export (0) Print
Expand All
Expand Minimize

UIElement.MouseLeftButtonDown Event

Occurs when the left mouse button is pressed while the mouse pointer is over this element.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

'Declaration
Public Event MouseLeftButtonDown As MouseButtonEventHandler
<object MouseLeftButtonDown="MouseButtonEventHandler" .../>

Implements

IInputElement.MouseLeftButtonDown

Identifier field

MouseLeftButtonDownEvent

Routing strategy

Direct

Delegate

MouseButtonEventHandler

Although this routed event 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 UIElement.

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.

The event data of this event exposes the event data of the underlying Mouse.MouseDown event. 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. If you mark MouseLeftButtonDown handled, you are essentially marking Mouse.MouseDown handled for all further listeners along the route, and on all related events. This possibly includes class-handler generated events such as MouseDoubleClick.

Conceptually, 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. For 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.

Important noteImportant

Some control classes 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. 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. 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.

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:

  • 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.

  • 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.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft