Syncfusion WPF FAQ
Questions and answers in this FAQ have been collected from newsgroup posts, various mailing lists and the employees of Syncfusion.

2. Concepts Element Tree

FAQ Home
   2.1 How can I enumerate all the descendants of a visual object ?



2.1 How can I enumerate all the descendants of a visual object ?


You can enumerate all the descendants of a visual object as follows :

[C#]

// Enumerate all the descendants of the visual object.
static public void EnumVisual(Visual myVisual)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
{
// Retrieve child visual at specified index value.
Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);

// Do processing of the child visual object.

// Enumerate children of the child visual object.
EnumVisual(childVisual);
}
}



© 2001-2010 Copyright Syncfusion Inc. All rights reserved.  |  Privacy Policy  |  Contact  |  Sitemap