コード例 #1
0
ファイル: TreeHelper.cs プロジェクト: quietsy/TeamNotifier
        public static T FindChild <T>(DependencyObject parent, Func <T, bool> additionalCheck) where T : DependencyObject
        {
            int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
            T   child;

            for (int index = 0; index < childrenCount; index++)
            {
                child = VisualTreeHelper.GetChild(parent, index) as T;

                if (child != null)
                {
                    if (additionalCheck == null)
                    {
                        return(child);
                    }
                    else
                    {
                        if (additionalCheck(child))
                        {
                            return(child);
                        }
                    }
                }
            }

            for (int index = 0; index < childrenCount; index++)
            {
                child = TreeHelper.FindChild <T>(VisualTreeHelper.GetChild(parent, index), additionalCheck);

                if (child != null)
                {
                    return(child);
                }
            }

            return(null);
        }
コード例 #2
0
ファイル: TreeHelper.cs プロジェクト: quietsy/TeamNotifier
 public static T FindChild <T>(DependencyObject parent) where T : DependencyObject
 {
     return(TreeHelper.FindChild <T>(parent, null));
 }