Print Logical Tree

private void PrintLogicalTree(int depth, object obj)

        {

            System.Diagnostics.Debug.WriteLine(new string(' ', depth) + obj);

            if (!(obj is DependencyObject))

            {

                return;

            }

            foreach (object child in LogicalTreeHelper.GetChildren(obj as DependencyObject))

            {

                PrintLogicalTree(depth + 1, child);

            }

        }

 

public AboutDialog()

        {

            InitializeComponent();

            PrintLogicalTree(0,this);

        }

原文地址:https://www.cnblogs.com/quietwalk/p/2262720.html