public class ElementTreeList { public delegate void Enumerate(DependencyObject target, int level); private static void EnumerateVisualChildren(DependencyObject src, Enumerate func, int level) { for (int index = 0; index < VisualTreeHelper.GetChildrenCount(src); index++) { DependencyObject child = VisualTreeHelper.GetChild(src, index); func(child, level); EnumerateVisualChildren(child, func, level