From ec945e2245c48d899df5af5d77ff01c710d9ef06 Mon Sep 17 00:00:00 2001 From: Thomas Kaltz III Date: Tue, 24 Sep 2013 15:05:16 -0400 Subject: [PATCH] Fix crash on click inside ItemsControl where ItemsSource.Count == 0 --- GongSolutions.Wpf.DragDrop/Utilities/VisualTreeExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GongSolutions.Wpf.DragDrop/Utilities/VisualTreeExtensions.cs b/GongSolutions.Wpf.DragDrop/Utilities/VisualTreeExtensions.cs index 5bd29b13..8e25a068 100644 --- a/GongSolutions.Wpf.DragDrop/Utilities/VisualTreeExtensions.cs +++ b/GongSolutions.Wpf.DragDrop/Utilities/VisualTreeExtensions.cs @@ -49,7 +49,7 @@ public static DependencyObject GetVisualAncestor(this DependencyObject d, Type t { var item = VisualTreeHelper.GetParent(d.FindVisualTreeRoot()); - while (item != null) { + while (item != null && type != null) { if (item.GetType() == type || item.GetType().IsSubclassOf(type)) { return item; } @@ -104,4 +104,4 @@ public static IEnumerable GetVisualDescendents(this DependencyObject d) wh yield break; } } -} \ No newline at end of file +}