Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
UIElement Class
UIElement Events
 MouseLeftButtonDown Event
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
UIElement..::.MouseLeftButtonDown Event

Occurs when the left mouse button is pressed (or when the tip of the stylus touches the tablet) while the mouse pointer is over a UIElement.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
Visual Basic (Declaration)
Public Event MouseLeftButtonDown As MouseButtonEventHandler
Visual Basic (Usage)
Dim instance As UIElement
Dim handler As MouseButtonEventHandler

AddHandler instance.MouseLeftButtonDown, handler
C#
public event MouseButtonEventHandler MouseLeftButtonDown
XAML Attribute Usage
<uiElement MouseLeftButtonDown="eventhandler"/>

The MouseLeftButtonDown event is raised when the left mouse button is pressed (or when the tip of the stylus touches the tablet PC) while the mouse pointer is over the UIElement. When the mouse button (or the tip of the stylus) is released, the MouseLeftButtonUp event is raised. However, if the mouse pointer (or the stylus) is moved over another object when the button is released, the UIElement that received the MouseLeftButtonDown event will not receive the MouseLeftButtonUp event. There is no discrete double-click event. A double-click consists of two sequences of MouseLeftButtonDown and MouseLeftButtonUp events.

The MouseLeftButtonDown event is a bubbling event. This means that if multiple MouseLeftButtonDown event handlers are registered for a sequence of objects connected by parent-child relationships in the object tree, the event is received by each object in that relationship. The event is raised by the object that directly receives the input condition that initiates the event, and then bubbles to each successive parent object. The bubbling metaphor indicates that the event starts at the source and works its way up the object tree. For a bubbling event, the sender available to the event handler identifies the object where the event is handled, not necessarily the object that actually received the input condition that initiated the event. To get the object that initiated the event, use the OriginalSource value of the event's RoutedEventArgs event data.

Mouse capture is a concept whereby an object can continue to receive mouse events, even if the mouse pointer (or the stylus) is no longer over the object's bounding area. In order to request mouse capture, the mouse left button (or the stylus) must be in a pressed (down) state. Therefore, a common point in code to call CaptureMouse is from within the MouseLeftButtonDown handler for a particular UIElement. For more information on mouse capture and scenarios where it is useful, see Mouse Support or How to: Drag and Drop Objects in UI Layout.

MouseLeftButtonDown and OnMouseLeftButtonDown

Controls that inherit MouseLeftButtonDown can provide special handling for the event, by overriding the OnMouseLeftButtonDown method. This might include marking the Handled value of the event as true, which has the effect of suppressing the MouseLeftButtonDown event on any instance of the control (and potentially any subclass of the control). For instance, ButtonBase implements OnMouseLeftButtonDown in such a way that the mouse left button captures the mouse and raises the ButtonBase-defined Click event. The implementation also sets Handled, which generally prevents mouse button actions from being reported as a MouseLeftButtonDown event that could be handled by a button instance. This is done because the Click event is more meaningful for the control's intended purpose. For more information, see OnMouseLeftButtonDown.

You can also register handlers such that they are invoked even for already-handled routed events. For more information, see AddHandler.

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker