How To Walk Through and Print The Logical and Visual Trees
How To Walk Through and Print The Logical and Visual Trees
namespace LogicalAndVisualTree
{
public class ConsoleHelper
{
/// <summary>
/// Allocates a new console for current process.
/// </summary>
[DllImport("kernel32.dll")]
public static extern Boolean AllocConsole();
/// <summary>
/// Frees the console.
/// </summary>
[DllImport("kernel32.dll")]
public static extern Boolean FreeConsole();
}
}
8. Now add the following code lines in the specified positions:
ConsoleHelper.AllocConsole();
ConsoleHelper.FreeConsole();
9. Now Press “F5” to execute the Program. Click on Button, it will show the Console Output,
displaying the Logical and Physical Trees.
In the same way, you can view Logical and Physical Tree of any control.