Kelary.Infrastructure/Helpers/UIHelper.cs
/// <summary>
/// Find all visual childrens of type <typeparamref name="T"/> for .
/// </summary>
/// <typeparam name="T">Type of childrens we looking for.</typeparam>
/// <param name="parent">Parent object.</param>
/// <returns></returns>
Find all visual childrens of type  for .
Find all visual childrens of type for .
public static IEnumerable<T> FindVisualChilds<T>(DependencyObject parent) where T : DependencyObject
        {
            if (parent != null)
            {
                (parent as FrameworkElement)?.ApplyTemplate();
                for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
                {
                    var child = VisualTreeHelper.GetChild(parent, i);
                    if (child != null && child is T)
                        yield return child as T;
                    foreach (var grandson in FindVisualChilds<T>(child))
                        yield return grandson;
                }
            }
        }
public static IEnumerable < T > FindVisualChilds < T > ( DependencyObject parent ) where T : DependencyObject { if ( parent != null ) { ( parent as FrameworkElement ) ? . ApplyTemplate ( ) ; for ( int i = 0 ; i < VisualTreeHelper . GetChildrenCount ( parent ) ; i ++ ) { var child = VisualTreeHelper . GetChild ( parent , i ) ; if ( child != null && child is T ) yield return child as T ; foreach ( var grandson in FindVisualChilds < T > ( child ) ) yield return grandson ; } } }
Find all visual childrens of type  for .
Find all visual childrens of type for .
// Return itself //if (element is T) //	yield return element as T; // Apply template if element is FrameworkElement
None
parent
DependencyObject
None
typeparam
Type of childrens we looking for.
Type of childrens we looking for .