Skip to content

Commit 9e85a9e

Browse files
committed
Merge pull request #125 from gerritvanroekel/master
Fix an issue when the itempresenter contains more ContentControls
2 parents a850796 + ee1d97e commit 9e85a9e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

GongSolutions.Wpf.DragDrop/Utilities/VisualTreeExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public static DependencyObject GetVisualAncestor(this DependencyObject d, Type t
9494
if (item == itemsControl) {
9595
return lastFoundItemByType;
9696
}
97-
if (item.GetType() == type || item.GetType().IsSubclassOf(type)) {
97+
if ((item.GetType() == type || item.GetType().IsSubclassOf(type))
98+
&& (itemsControl == null || itemsControl.ItemContainerGenerator.IndexFromContainer(item) >= 0)) {
9899
lastFoundItemByType = item;
99100
}
100101
item = VisualTreeHelper.GetParent(item);

0 commit comments

Comments
 (0)