Example #1
0
        /// <summary>
        /// Returns a collection of child elements.
        /// </summary>
        public static IEnumerable <DependencyObject> Elements(this DependencyObject item)
        {
            ILinqTree <DependencyObject> adapter = new VisualTreeAdapter(item);

            foreach (var child in adapter.Children())
            {
                yield return(child);
            }
        }
Example #2
0
        /// <summary>
        /// Returns a collection of ancestor elements.
        /// </summary>
        public static IEnumerable <DependencyObject> Ancestors(this DependencyObject item)
        {
            ILinqTree <DependencyObject> adapter = new VisualTreeAdapter(item);

            var parent = adapter.Parent;

            while (parent != null)
            {
                yield return(parent);

                adapter = new VisualTreeAdapter(parent);
                parent  = adapter.Parent;
            }
        }