Skip to content

Commit

Permalink
Reworked Finding Visual tree parent control to not use recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcidev committed Aug 15, 2024
1 parent 045adf9 commit 7e95a58
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Client.UI/Utilities/VisulTreeExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ public static class VisulTreeExtension
{
public static T FindParent<T>(this DependencyObject obj) where T : DependencyObject
{
if (obj == null)
return null;
while (obj != null && obj is not T)
obj = VisualTreeHelper.GetParent(obj);

obj = VisualTreeHelper.GetParent(obj);
if (obj is T)
return obj as T;

return FindParent<T>(obj);
return obj as T;
}
}
}

0 comments on commit 7e95a58

Please sign in to comment.