private static void GetChildTree(this FrameworkElement root, string prefix, string addPrefix, List <string> results) { string str = (!string.IsNullOrEmpty(root.Name) ? root.Name : "[Anon]") + " " + root.GetType().Name; results.Add(prefix + str); foreach (FrameworkElement root1 in ExtensionMethods.GetVisualChildren(root)) { ExtensionMethods.GetChildTree(root1, prefix + addPrefix, addPrefix, results); } }
public static IEnumerable <FrameworkElement> GetVisualDescendents(this FrameworkElement root) { Queue <IEnumerable <FrameworkElement> > toDo = new Queue <IEnumerable <FrameworkElement> >(); toDo.Enqueue(ExtensionMethods.GetVisualChildren(root)); while (toDo.Count > 0) { IEnumerable <FrameworkElement> children = toDo.Dequeue(); foreach (FrameworkElement root1 in children) { yield return(root1); toDo.Enqueue(ExtensionMethods.GetVisualChildren(root1)); } } }