From 9b782f35e55c112a0b344107eda6123bc593e341 Mon Sep 17 00:00:00 2001 From: Andreas Schmitt Date: Thu, 4 Jul 2024 16:02:47 +0200 Subject: [PATCH] Always correctly reset state when drag is cancelled --- .../DragDrop.Properties.cs | 2 -- src/GongSolutions.WPF.DragDrop/DragDrop.cs | 15 ++++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs b/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs index 04ade227..72708c5c 100644 --- a/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs +++ b/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs @@ -100,7 +100,6 @@ private static void OnIsDragSourceChanged(DependencyObject d, DependencyProperty uiElement.PreviewTouchUp -= DragSourceOnTouchUp; uiElement.PreviewTouchMove -= DragSourceOnTouchMove; - uiElement.QueryContinueDrag -= DragSourceOnQueryContinueDrag; uiElement.GiveFeedback -= DragSourceOnGiveFeedback; if ((bool)e.NewValue) @@ -113,7 +112,6 @@ private static void OnIsDragSourceChanged(DependencyObject d, DependencyProperty uiElement.PreviewTouchUp += DragSourceOnTouchUp; uiElement.PreviewTouchMove += DragSourceOnTouchMove; - uiElement.QueryContinueDrag += DragSourceOnQueryContinueDrag; uiElement.GiveFeedback += DragSourceOnGiveFeedback; } } diff --git a/src/GongSolutions.WPF.DragDrop/DragDrop.cs b/src/GongSolutions.WPF.DragDrop/DragDrop.cs index d1b5d8a5..b375f029 100644 --- a/src/GongSolutions.WPF.DragDrop/DragDrop.cs +++ b/src/GongSolutions.WPF.DragDrop/DragDrop.cs @@ -655,6 +655,10 @@ private static void DoDragSourceMove(object sender, Func g if (dragDropEffects == DragDropEffects.None) { dragHandler.DragCancelled(); + DragDropPreview = null; + DragDropEffectPreview = null; + DropTargetAdorner = null; + Mouse.OverrideCursor = null; } dragHandler.DragDropOperationFinished(dragDropEffects, dragInfo); @@ -678,17 +682,6 @@ private static void DoDragSourceMove(object sender, Func g } } - private static void DragSourceOnQueryContinueDrag(object sender, QueryContinueDragEventArgs e) - { - if (e.Action == DragAction.Cancel || e.EscapePressed || (e.KeyStates.HasFlag(DragDropKeyStates.LeftMouseButton) == e.KeyStates.HasFlag(DragDropKeyStates.RightMouseButton))) - { - DragDropPreview = null; - DragDropEffectPreview = null; - DropTargetAdorner = null; - Mouse.OverrideCursor = null; - } - } - private static void DropTargetOnDragLeave(object sender, DragEventArgs e) { SetIsDragOver(sender as DependencyObject, false);