Exemple #1
0
        /// <summary>
        /// Finds a parent of the component where the parent type is being T (bottom-up)<br/>
        /// Returns null if such a parent not found
        /// </summary>
        /// <typeparam name="T">Parent type</typeparam>
        /// <param name="component">Component</param>
        /// <returns></returns>
        public static T FindParent <T>(Component component) where T : Component
        {
            List <DisplayListMember> chain = ComponentUtil.GetParentChain(component, false);

            foreach (DisplayListMember c in chain)
            {
                if (c.GetType() == typeof(T) && c is T)
                {
                    return((T)c);
                }
            }
            return(null);
        }