src/Foundation/Presentation/Gimela.Presentation.Controls/Controls/Timeline/Helpers/VisualTreeExtraHelper.cs
/// <summary>
/// Find a parent object of type parentItem in the visual tree
/// </summary>
/// <typeparam name="TParentType"></typeparam>
/// <param name="outerDepObj"></param>
/// <returns></returns>
Find a parent object of type parentItem in the visual tree
Find a parent object of type parentItem in the visual tree
public static TParentType FindVisualParent<TParentType>(DependencyObject outerDepObj) where TParentType : DependencyObject
        {
            DependencyObject dObj = VisualTreeHelper.GetParent(outerDepObj);
            if (dObj == null)
                return null;
            if (dObj is TParentType)
                return dObj as TParentType;
            while ((dObj = VisualTreeHelper.GetParent(dObj)) != null)
            {
                if (dObj is TParentType)
                    return dObj as TParentType;
            }
            return null;
        }
public static TParentType FindVisualParent < TParentType > ( DependencyObject outerDepObj ) where TParentType : DependencyObject { DependencyObject dObj = VisualTreeHelper . GetParent ( outerDepObj ) ; if ( dObj == null ) return null ; if ( dObj is TParentType ) return dObj as TParentType ; while ( ( dObj = VisualTreeHelper . GetParent ( dObj ) ) != null ) { if ( dObj is TParentType ) return dObj as TParentType ; } return null ; }
Find a parent object of type parentItem in the visual tree
Find a parent object of type parentItem in the visual tree
None
outerDepObj
DependencyObject
None
typeparam
None