UIElement.MouseDown
Event

Definition

In This Article

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

public event System.Windows.Input.MouseButtonEventHandler MouseDown;

Remarks

This event creates an alias for the <xref:System.Windows.Input.Mouse.MouseDown?displayProperty=nameWithType> attached event for this class, so that MouseDown is part of the class members list when UIElement is inherited as a base element. Event handlers that are attached to the MouseDown event are attached to the underlying <xref:System.Windows.Input.Mouse.MouseDown?displayProperty=nameWithType> attached event and receive the same event data instance.

Some controls 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 MouseDown 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.