Export (0) Print
Expand All
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.MouseLeave Event

July 28, 2014

Occurs when a touch event occurs outside the bounding area of a UIElement.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public event MouseEventHandler MouseLeave
<uiElement MouseLeave="eventhandler"/>

Use a handler based on MouseEventHandler to handle this event. For more information on how to handle touch events, see Quickstart: Touch input for Windows Phone 8.

The MouseLeave event can be defined for any UIElement-derived class, such as Canvas, TextBlock, or Rectangle.

The MouseLeave event is raised in response to a touch event occurring outside the object's bounding area.

You can define multiple MouseLeave events for objects in XAML content. However, if a child object and its parent object both define a MouseLeave event, the parent object's MouseLeave event occurs before the child object's MouseLeave event. This is not a case of a bubbling event; it indicates only that entered touch event has occurred for both objects, potentially at different times depending on the object layout and composition of the visual tree.

Unlike the MouseEnter event, the MouseLeave event does not provide the touch position in event data, because the position of the touch event relative to the object is unknown when it is out of bounds. Because it is always null, you generally should not use the event data from your MouseLeave event handler, although you may still be interested in the sender parameter.

MouseLeave events do not route, they can only be handled on the element that raises them.

MouseLeave and OnMouseLeave

Controls that inherit MouseLeave can provide handling for the event that acts as handler for all instances, by overriding the OnMouseLeave method. OnMouseLeave can be useful either for setting visual state, or for public or internal state properties. For instance, Slider implements OnMouseLeave in order to check the Thumb element's value for IsDragging (which cancels a particular behavior mode), and also to set visual state. For more information, see OnMouseLeave.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft