public static IEnumerable<T> FindVisualChildren<T>(DependencyObject depObj) where T : DependencyObject<br /> {<br /> if (depObj != null)<br /> {<br /> for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)<br /> {<br /> DependencyObject child = VisualTreeHelper.GetChild(depObj, i);<br /> if (child != null && child is T)<br /> {<br /> yield return (T)child;<br /> }<br /> <br /> foreach (T childOfChild in FindVisualChildren<T>(child))<br /> {<br /> yield return childOfChild;<br /> }<br /> }<br /> }<br /> }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)