Compartir a través de


UIElement.MouseLeftButtonUp Event

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Occurs when the left mouse button is released (or the tip of the stylus is removed from the tablet) while the mouse (or the stylus) is over a UIElement (or while a UIElement holds mouse capture).

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Event MouseLeftButtonUp As MouseButtonEventHandler
public event MouseButtonEventHandler MouseLeftButtonUp
<uiElement MouseLeftButtonUp="eventhandler"/>

Remarks

Use a handler based on MouseButtonEventHandler to handle this event. For more information on how to handle mouse events, see Mouse Support.

The MouseLeftButtonDown event is raised when the left mouse button is pressed while the mouse pointer is over the object. When the mouse button is released (or the tip of the stylus is removed from the tablet PC), the MouseLeftButtonUp event is raised. If the mouse pointer (or the stylus) is moved over another object when the button is released, the object that received the MouseLeftButtonDown event will not necessarily receive the MouseLeftButtonUp event. However, you can continue to receive mouse events such as MouseMove and MouseLeftButtonUp from the perspective of the UIElement where MouseLeftButtonDown occurred, if you have that object initiate mouse capture by calling CaptureMouse. If the mouse is captured, it is generally a good idea to release mouse capture from the object that holds capture as part of your handling for MouseLeftButtonUp, by calling ReleaseMouseCapture on the sender of the event. Mouse capture will be lost anyways because mouse capture is only retained by the input system while the mouse left button is pressed. Mouse capture and mouse events are typically only relevant while the mouse pointer (or the stylus) is within the Silverlight plug-in content area. However, if the mouse pointer (or the stylus) exits and then re-enters the Silverlight plug-in content area, mouse capture state is retained so long as the mouse left button is still down. Also, if the mouse button is released while an object holds capture, the mouse pointer can report its position in the overall screen coordinate space from MouseLeftButtonUp even if the mouse pointer is completely outside the hosting browser (although note that this particular case might not be accurately reported by all browsers and platforms).

There is no discrete double-click event. A double-click consists of two sequences of MouseLeftButtonDown and MouseLeftButtonUp events.

Routed Event Behavior

The MouseLeftButtonUp event is a bubbling event. This means that if multiple MouseLeftButtonUp 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 bubbling metaphor indicates that the event starts at the object that directly receives the input condition 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.

MouseLeftButtonUp and OnMouseLeftButtonUp

Controls that inherit MouseLeftButtonUp can provide handling for the event that acts as handler for all instances, by overriding the OnMouseLeftButtonUp method. This might include marking the Handled value of the event as true, which has the effect of suppressing the MouseLeftButtonUp event on any instance of the control (and potentially any subclass of the control). For instance, ButtonBase implements OnMouseLeftButtonUp in such a way that the mouse left button releases mouse capture. The implementation also sets Handled, which prevents mouse button actions from being reported as a MouseLeftButtonUp 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 OnMouseLeftButtonUp.

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

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

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