When you install the Longhorn Developer Preview SDK, it adds a number of new project templates to the VB and C# IDE:

  • application
  • custom control
  • document project
  • hosted application
  • navigation application
  • screen saver
  • sidebar tile.

Within a project, you can easily add different XAML files based on a series of pre-defined templates.

Here's a very basic example of a XAML window definition:

   <FlowPanel xmlns="http://schemas.microsoft.com/2003/xaml">
   Here's a listbox: <ListBox ID="listBox1">

You can create styles for items (to set a consistent look or feel across multiple instances of a control). These are created within a .resources element that matches the panel (e.g. <FlowPanel.Resources>). These are called compound property tags.

What happens when you build a XAML-enabled application? The XAML gets turned into two separate things: a .g.cs file (which is a partial class containing any code that you've included in the XAML file), and a .baml file (which contains a binary pre-processed representation of the rest of the XAML). The .g.cs file gets compiled in combination with any code-behind class you have to produce the final .exe.

There are five element families: controls, panels, decorators, shapes and content elements. Each of these primitives can be subclassed to modify the standard behaviour.

Panels come in a number of different styles: DockPanel, GridPanel, FlowPanel, TablePanel and Canvas are all included with the Longhorn SDK. The DockPanel allows you to create multiple controls that are each docked, much like the docking property of controls in WinForms today. GridPanel provides a simple grid view that allows controls to be aligned in multiple columns. FlowPanel simply flows controls (either horizontally or vertically), much like IE shows HTML. Panels can be nested within other panels, so you can mix and match different layout types within a form. Or you might have a DockPanel within a DockPanel in order to dock items within a master panel control.

The concept of a document is far stronger in Avalon than in the traditional WinForms environment. Like MFC, there is a view infrastructure. One clever feature is that the SDK installs an Avalon printer driver into Longhorn that can be used to generate these documents. So, for example, if you printed a Powerpoint slide deck with the printer driver, it would generate a XAML document that could be rendered as part of a form.