Live Chat Icon For mobile
Live Chat Icon

How do I enumerate child objects in a visual tree ?

Platform: WPF| Category: 2D Graphics

WPF has a “VisualTreeHelper” class that provides the functionality to retrieve the parent objects of a visual object using the GetParent() method and child objects of a visual object using the GetChild() method by specifying the index value of the child.

The following code snippet is used to enumerate all the child objects of a visual object.


public void ChildEnum(Visual Visualobj)
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(Visualobj); i++)
Visual childVisual = (Visual)VisualTreeHelper.GetChild(Visualobj, i);

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.