From b23f8ef44e06e84a883de8ef3a99b716f53a860b Mon Sep 17 00:00:00 2001 From: emsaks Date: Thu, 8 Oct 2015 20:20:12 +0300 Subject: [PATCH 1/4] Update DropInfo.cs if VisualTarget is not ItemsControl then VisualTargetItem = VisualTarget. Allows HighlightAdorner to be used in IDropTarget.Drag. --- GongSolutions.Wpf.DragDrop/DropInfo.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GongSolutions.Wpf.DragDrop/DropInfo.cs b/GongSolutions.Wpf.DragDrop/DropInfo.cs index 267d3820..4eaa8084 100644 --- a/GongSolutions.Wpf.DragDrop/DropInfo.cs +++ b/GongSolutions.Wpf.DragDrop/DropInfo.cs @@ -155,6 +155,8 @@ public DropInfo(object sender, DragEventArgs e, DragInfo dragInfo) this.InsertPosition |= RelativeInsertPosition.TargetItemCenter; } //System.Diagnostics.Debug.WriteLine("==> DropInfo: InsPos={0}, InsIndex={1}, X={2}, Item={3}", this.InsertPosition, this.InsertIndex, currentXPos, item); + } else { + this.VisualTargetItem = this.VisualTarget; } } else @@ -344,4 +346,4 @@ public enum RelativeInsertPosition AfterTargetItem = 1, TargetItemCenter = 2 } -} \ No newline at end of file +} From e65d8561b8b75c40580503c8cd6f3598da6f462d Mon Sep 17 00:00:00 2001 From: emsaks Date: Thu, 8 Oct 2015 20:23:54 +0300 Subject: [PATCH 2/4] Update DragDrop.cs allow adorners on non-ItemControls (e.g. a label representing a collection, who's collection is rendered with it.) --- GongSolutions.Wpf.DragDrop/DragDrop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GongSolutions.Wpf.DragDrop/DragDrop.cs b/GongSolutions.Wpf.DragDrop/DragDrop.cs index ee60801d..52ae2006 100644 --- a/GongSolutions.Wpf.DragDrop/DragDrop.cs +++ b/GongSolutions.Wpf.DragDrop/DragDrop.cs @@ -891,7 +891,7 @@ private static void DropTarget_PreviewDragOver(object sender, DragEventArgs e) var adornedElement = itemsControl is TabControl ? itemsControl.GetVisualDescendent() - : (itemsControl.GetVisualDescendent() ?? itemsControl.GetVisualDescendent() as UIElement); + : (itemsControl.GetVisualDescendent() ?? itemsControl.GetVisualDescendent() as UIElement) ?? itemsControl; if (adornedElement != null) { if (dropInfo.DropTargetAdorner == null) { From b30305f6b06e76445db34c7cb7a9f54686c9a09c Mon Sep 17 00:00:00 2001 From: emsaks Date: Thu, 8 Oct 2015 21:50:20 +0300 Subject: [PATCH 3/4] fixed bad paren. --- GongSolutions.Wpf.DragDrop/DragDrop.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GongSolutions.Wpf.DragDrop/DragDrop.cs b/GongSolutions.Wpf.DragDrop/DragDrop.cs index 52ae2006..7ffd073c 100644 --- a/GongSolutions.Wpf.DragDrop/DragDrop.cs +++ b/GongSolutions.Wpf.DragDrop/DragDrop.cs @@ -891,7 +891,7 @@ private static void DropTarget_PreviewDragOver(object sender, DragEventArgs e) var adornedElement = itemsControl is TabControl ? itemsControl.GetVisualDescendent() - : (itemsControl.GetVisualDescendent() ?? itemsControl.GetVisualDescendent() as UIElement) ?? itemsControl; + : (itemsControl.GetVisualDescendent() ?? itemsControl.GetVisualDescendent() as UIElement ?? itemsControl); if (adornedElement != null) { if (dropInfo.DropTargetAdorner == null) { From 87f0f08479ce4a9f51ee3c2e345c2a6bc9501d09 Mon Sep 17 00:00:00 2001 From: emsaks Date: Thu, 8 Oct 2015 21:55:13 +0300 Subject: [PATCH 4/4] wrong position of code block --- GongSolutions.Wpf.DragDrop/DropInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GongSolutions.Wpf.DragDrop/DropInfo.cs b/GongSolutions.Wpf.DragDrop/DropInfo.cs index 4eaa8084..fec8bcdf 100644 --- a/GongSolutions.Wpf.DragDrop/DropInfo.cs +++ b/GongSolutions.Wpf.DragDrop/DropInfo.cs @@ -155,9 +155,7 @@ public DropInfo(object sender, DragEventArgs e, DragInfo dragInfo) this.InsertPosition |= RelativeInsertPosition.TargetItemCenter; } //System.Diagnostics.Debug.WriteLine("==> DropInfo: InsPos={0}, InsIndex={1}, X={2}, Item={3}", this.InsertPosition, this.InsertIndex, currentXPos, item); - } else { - this.VisualTargetItem = this.VisualTarget; - } + } } else { @@ -165,6 +163,8 @@ public DropInfo(object sender, DragEventArgs e, DragInfo dragInfo) this.InsertIndex = itemsControl.Items.Count; //System.Diagnostics.Debug.WriteLine("==> DropInfo: {0}, item=NULL, {1}", this.InsertPosition, this.InsertIndex); } + } else { + this.VisualTargetItem = this.VisualTarget; } }