Skip to main content
.NET Framework Class Library
DragDropDragLeave Attached Event

Occurs when an object is dragged out of the bounds of an element that is acting as a drop target without being dropped.

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
Syntax
See [%$TOPIC/ms596511_en-us_VS_110_1_0_0_0_0%], [%$TOPIC/ms596511_en-us_VS_110_1_0_0_0_1%]
See [%$TOPIC/ms596511_en-us_VS_110_1_0_1_0_0%], [%$TOPIC/ms596511_en-us_VS_110_1_0_1_0_1%]
See [%$TOPIC/ms596511_en-us_VS_110_1_0_2_0_0%], [%$TOPIC/ms596511_en-us_VS_110_1_0_2_0_1%]
See [%$TOPIC/ms596511_en-us_VS_110_1_0_3_0_0%], [%$TOPIC/ms596511_en-us_VS_110_1_0_3_0_1%]
See [%$TOPIC/ms596511_en-us_VS_110_1_0_4_0_0%], [%$TOPIC/ms596511_en-us_VS_110_1_0_4_0_1%]
<object DragDrop.DragLeave="[%$TOPIC/ms596511_en-us_VS_110_1_0_5_0_0%]" .../>
Remarks

This event is raised once each time an object is dragged out of the bounds of an element that is acting as a drop target without being dropped. This event is not raised if the element’s AllowDrop property is false.

You typically handle this event to undo any changes that you made in the DragEnter event handler.

Routed Event Information

Identifier field

DragLeaveEvent

Routing strategy

Bubbling

Delegate

DragEventHandler

The corresponding tunneling event is PreviewDragLeave.

Examples

The following example shows the DragLeave event handler for an Ellipse element. This code undoes the preview performed in the DragEnter event handler by applying the saved Brush to the ellipse.

Private Sub Ellipse_DragLeave(ByVal sender As System.Object, ByVal e As System.Windows.DragEventArgs)
    Dim ellipse = TryCast(sender, Ellipse)
    If ellipse IsNot Nothing Then
        ellipse.Fill = _previousFill
    End If 
End Sub
private void ellipse_DragLeave(object sender, DragEventArgs e)
{
    Ellipse ellipse = sender as Ellipse;
    if (ellipse != null)
    {
        ellipse.Fill = _previousFill;
    }
}
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1