DragDrop.DragLeave DragDrop.DragLeave DragDrop.DragLeave 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.

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. 如果不會引發這個事件的項目AllowDrop屬性是falseThis event is not raised if the element's AllowDrop property is false.

您通常會處理這個事件,以復原對所做的任何變更DragEnter事件處理常式。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 - 委派Delegate DragEventHandler

對應的通道事件是PreviewDragLeaveThe corresponding tunneling event is PreviewDragLeave.

適用於

另請參閱