Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElement.MouseDown Event

Occurs when any mouse button is pressed while the 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

public event MouseButtonEventHandler MouseDown
<object MouseDown="MouseButtonEventHandler" .../>

Identifier field

MouseDownEvent

Routing strategy

Bubbling

Delegate

MouseButtonEventHandler

  • The corresponding tunneling event is PreviewMouseDown.

  • Override OnMouseDown to implement class handling for this event in derived classes.

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 UIElement is inherited as a base element. 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.

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. 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. See Remarks for MouseLeftButtonDown or MouseRightButtonDown.

Important noteImportant

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.

.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