Skip to content

Commit

Permalink
Merge pull request #143 from emsaks/master
Browse files Browse the repository at this point in the history
Allow target adorners on non-ItemsControls
  • Loading branch information
punker76 committed Oct 8, 2015
2 parents c0e65e3 + 87f0f08 commit 269b185
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GongSolutions.Wpf.DragDrop/DragDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ private static void DropTarget_PreviewDragOver(object sender, DragEventArgs e)
var adornedElement =
itemsControl is TabControl
? itemsControl.GetVisualDescendent<TabPanel>()
: (itemsControl.GetVisualDescendent<ItemsPresenter>() ?? itemsControl.GetVisualDescendent<ScrollContentPresenter>() as UIElement);
: (itemsControl.GetVisualDescendent<ItemsPresenter>() ?? itemsControl.GetVisualDescendent<ScrollContentPresenter>() as UIElement ?? itemsControl);

if (adornedElement != null) {
if (dropInfo.DropTargetAdorner == null) {
Expand Down
6 changes: 4 additions & 2 deletions GongSolutions.Wpf.DragDrop/DropInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,16 @@ 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.TargetCollection = itemsControl.ItemsSource ?? itemsControl.Items;
this.InsertIndex = itemsControl.Items.Count;
//System.Diagnostics.Debug.WriteLine("==> DropInfo: {0}, item=NULL, {1}", this.InsertPosition, this.InsertIndex);
}
} else {
this.VisualTargetItem = this.VisualTarget;
}
}

Expand Down Expand Up @@ -344,4 +346,4 @@ public enum RelativeInsertPosition
AfterTargetItem = 1,
TargetItemCenter = 2
}
}
}

0 comments on commit 269b185

Please sign in to comment.