Using XamlPad to Test Content

XamlPad is a Windows SDK tool that gives you a simple way to experiment with creating XAML content--the XAML can be instantly displayed as WPF content. For example, I use XamlPad to test WPF features, such as OpenType fonts. By changing differing property values of the Typography class, I can see the immediate results of using special OpenType typographic features, such as stylistic alternates:

Notice that a FlowDocument element is used to host the text content. This element provides search, navigation, pagination, and content scaling support. Try scaling the content and appreciate all the hard work WPF is doing for you!

Viewing the Visual Tree
Analyzing the visual tree hierarchy using XAMLPad may give you insight into how control template expansion works. This knowledge may help you understand the performance costs and tradeoffs of the design of your user interface. To view the visual tree that corresponds to your XAML content, click the Show Visual Tree button on the menu bar. The XAML content is represented as visual tree nodes in the Visual Tree Explorer panel of XamlPad:

Click on a node to expand its hierarchy. Notice how the Label, TextBox, and Button controls each display a separate visual object hierarchy in the Visual Tree Explorer panel of XamlPad. This is because WPF controls have a ControlTemplate that contains the visual tree of that control. When you explicitly reference a control, you implicitly reference its visual hierarchy. For more information on visual objects and the visual tree, see the Visual Layer Overview.

Viewing Properties of a Visual Object
You can view the property settings of an item in the Visual Tree Explorer by selecting the item. The Property Tree Explorer panel, below the Visual Tree Explorer panel, displays the current property settings for the selected visual object. In this case, I've selected the Label. I've also exanded two of the base classes that Label is derived from:

Label
   - ContentControl
       - Control

Notice that Control contains such properties as Background and FontFamily, making this class one of the core base classes for WPF user interface controls. You could continue expanding derived classes, such as FrameworkElement, to view even more properties.

Enjoy,
Lorin

About Us


We are the Windows Presentation Foundation SDK writers and editors.