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 +}