public override IEnumerable <DependencyObject> GetChildren(DependencyObject element)
        {
            var list = new List <DependencyObject>();

            if (element == null)
            {
                return(list);
            }

            try
            {
                var children = new List <DependencyObject>();

                if (element is Visual ||
                    element is Visual3D)
                {
                    children = VisualTreeNodeProvider.GetChildren(element).ToList();
                    for (int i = 0; i < children.Count; i++)
                    {
                        var child = children[i];

                        if (child != null)
                        {
                            list.Add(child);
                        }
                    }
                }

                if (element is IContentHost)
                {
                    children = LogicalTreeNodeProvider.GetChildren(element).ToList();
                    for (int i = 0; i < children.Count; i++)
                    {
                        var child = children[i];

                        if (child != null)
                        {
                            list.Add(child);
                        }
                    }
                }

                /*else
                 * {
                 *  children = LogicalTreeNodeProvider.GetChildren(element).Where(x => !(element is Visual || element is Visual3D)).ToList();
                 *  for (int i = 0; i < children.Count; i++)
                 *  {
                 *      var child = children[i];
                 *
                 *      if (child != null)
                 *      {
                 *          list.Add(child);
                 *      }
                 *  }
                 * }*/
            }
            catch { }
            return(list);
        }
예제 #2
0
        public override DependencyObject GetParent(DependencyObject element)
        {
            if (element == null)
            {
                return(null);
            }

            if (element is Visual ||
                element is Visual3D)
            {
                return(VisualTreeNodeProvider.GetParent(element));
            }
            else
            {
                return(LogicalTreeNodeProvider.GetParent(element));
            }
        }
예제 #3
0
        public override IEnumerable <DependencyObject> GetChildren(DependencyObject element)
        {
            var list = new List <DependencyObject>();

            if (element == null)
            {
                return(list);
            }

            try
            {
                if (element is Visual ||
                    element is Visual3D)
                {
                    var children = VisualTreeNodeProvider.GetChildren(element).ToList();
                    for (int i = 0; i < children.Count; i++)
                    {
                        var child = children[i];

                        if (child != null)
                        {
                            list.Add(child);
                        }
                    }
                }
                else
                {
                    var children = LogicalTreeNodeProvider.GetChildren(element).ToList();
                    for (int i = 0; i < children.Count; i++)
                    {
                        var child = children[i];

                        if (child != null)
                        {
                            list.Add(child);
                        }
                    }
                }
            }
            catch { }
            return(list);
        }
 public override bool IsInTree(DependencyObject element)
 {
     return(VisualTreeNodeProvider.IsInTree(element));
 }