DragDrop.DragLeave 附加事件

定义

在将对象拖出用作拖放目标的元素边界,且未放置时发生。Occurs when an object is dragged out of the bounds of an element that is acting as a drop target without being dropped.

see AddDragLeaveHandler, and RemoveDragLeaveHandler
see AddDragLeaveHandler, and RemoveDragLeaveHandler
see AddDragLeaveHandler, and RemoveDragLeaveHandler

示例

下面的示例演示 DragLeave 元素的 Ellipse 事件处理程序。The following example shows the DragLeave event handler for an Ellipse element. 此代码通过将保存的 Brush 应用到椭圆来撤销 DragEnter 事件处理程序中执行的预览。This code undoes the preview performed in the DragEnter event handler by applying the saved Brush to the ellipse.

private void ellipse_DragLeave(object sender, DragEventArgs e)
{
    Ellipse ellipse = sender as Ellipse;
    if (ellipse != null)
    {
        ellipse.Fill = _previousFill;
    }
}
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

注解

此事件在每次将对象拖出作为放置目标的元素边界时引发一次,而不会被删除。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. 如果元素的 @no__t 0 属性 @no__t 为-1,则不会引发此事件。This event is not raised if the element's AllowDrop property is false.

你通常会处理此事件,以撤消你在 @no__t 0 事件处理程序中进行的任何更改。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

对应的隧道事件为 PreviewDragLeaveThe corresponding tunneling event is PreviewDragLeave.

适用于

另请参阅