diff --git a/Utility.WPF/DependencyObjectExtensions.cs b/Utility.WPF/DependencyObjectExtensions.cs index d54f084..92acfb2 100644 --- a/Utility.WPF/DependencyObjectExtensions.cs +++ b/Utility.WPF/DependencyObjectExtensions.cs @@ -9,16 +9,21 @@ public static class DependencyObjectExtensions /// Finds the first parent of a specified type for a given dependency object. /// /// The type of the parent to find. - /// The dependency object to start the search from. + /// The dependency object to start the search from. /// The first parent of the specified type, or null if no such parent exists. - public static TDependencyType? FindParentOfType(this DependencyObject d) + public static TDependencyType? FindParentOfType(this DependencyObject dependencyObject) { - if (d is TDependencyType type) + if (dependencyObject is null) + { + return default; + } + + if (dependencyObject is TDependencyType type) { return type; } - return FindParentOfType(VisualTreeHelper.GetParent(d)); + return FindParentOfType(VisualTreeHelper.GetParent(dependencyObject)); } ///