DragDrop.DragLeave 附加事件
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從置放目標項目的界限拖曳出物件但不置放時發生。
C#
see AddDragLeaveHandler, and RemoveDragLeaveHandler
see AddDragLeaveHandler, and RemoveDragLeaveHandler
see AddDragLeaveHandler, and RemoveDragLeaveHandler
下列範例示範 DragLeave 項目的 Ellipse 事件處理常式。 這個程式碼透過將儲存的 Brush 套用至橢圓形,來復原在 DragEnter 事件處理常式中執行的預覽。
C#
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
每次將物件拖出做為置放目標的專案界限時,就會引發這個事件一次,而不會被捨棄。 如果專案的 AllowDrop 屬性為 false
,則不會引發這個事件。
您通常會處理此事件,以復原您在事件處理常式中 DragEnter 所做的任何變更。
識別碼欄位 | DragLeaveEvent |
路由策略 | 鼓 泡 |
代理人 | DragEventHandler |
對應的通道事件為 PreviewDragLeave 。
產品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |