diff --git a/GongSolutions.Wpf.DragDrop/DragDrop.cs b/GongSolutions.Wpf.DragDrop/DragDrop.cs index ee60801d..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.GetVisualDescendent() ?? itemsControl.GetVisualDescendent() as UIElement ?? itemsControl); if (adornedElement != null) { if (dropInfo.DropTargetAdorner == null) { diff --git a/GongSolutions.Wpf.DragDrop/DropInfo.cs b/GongSolutions.Wpf.DragDrop/DropInfo.cs index 267d3820..fec8bcdf 100644 --- a/GongSolutions.Wpf.DragDrop/DropInfo.cs +++ b/GongSolutions.Wpf.DragDrop/DropInfo.cs @@ -155,7 +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 { @@ -163,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; } } @@ -344,4 +346,4 @@ public enum RelativeInsertPosition AfterTargetItem = 1, TargetItemCenter = 2 } -} \ No newline at end of file +}