How to print Parent hierarchy of an element?
DependencyObject _parent = myGrid.Parent;
while (_parent != null)
{
System.Diagnostics.Debug.WriteLine(_parent);
_parent = ((FrameworkElement)_parent)?.Parent;
}
Every framework element has a Parent property, we can loop through like above code and print parent of particular element.
No comments:
Post a Comment