Ejemplo n.º 1
0
        /// <summary>
        /// The get visual tree.
        /// </summary>
        /// <param name="root">
        /// The root.
        /// </param>
        /// <returns>
        /// The <see cref="VisualItem"/>.
        /// </returns>
        private VisualItem GetVisualTree(DependencyObject root)
        {
            if (root == null)
            {
                return null;
            }

            var rootItem = new VisualItem(root);
            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
            {
                var child = VisualTreeHelper.GetChild(root, i);
                var subItem = this.GetVisualTree(child);
                rootItem.Children.Add(subItem);
            }

            return rootItem;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The window loaded.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            this.LogicalRootItem = this.GetLogicalTree(this);

            this.VisualRootItem = this.GetVisualTree(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The get logical tree.
        /// </summary>
        /// <param name="root">
        /// The root.
        /// </param>
        /// <returns>
        /// The <see cref="VisualItem"/>.
        /// </returns>
        private VisualItem GetLogicalTree(DependencyObject root)
        {
            if (root == null)
            {
                return null;
            }

            var rootItem = new VisualItem(root);
            foreach (var child in LogicalTreeHelper.GetChildren(root))
            {
                var logicalChild = this.GetLogicalTree(child as DependencyObject);
                if (logicalChild != null)
                {
                    rootItem.Children.Add(logicalChild);
                }
            }

            return rootItem;
        }