Building a Longhorn Document


You aren t restricted to building applications with XAML. You can also use XAML files to create a highly interactive, intelligently rendered, adaptive document for a user to read. In this case, your XAML files collectively represent pages of a document. You can use the MSBuild engine to build such documents.

The changes to the project file to build a document instead of an application are minor:

  • Set the value of the TargetType property to Document .

  • Import the WindowsDocument.target project for the appropriate build rules.

  • Include all other project files as usual.

It s important to understand what a TargetType of Document really produces. When you build a Document , the build output is a .container file, and the build system optimizes the contents of the container for download rather than speed. A container file is an extension of the Windows Structured Storage, also known as DocFile, format. Longhorn container handling provides features that allow rendering of partially downloaded files. Therefore, you don t need the entire container downloaded before the application starts running.

In addition, when you ask MSBuild to create a container file, it compiles each XAML file into a binary representation of the XML, called binary XAML (BAML). BAML is far more compact than either the original text file or a compiled-to-IL assembly. BAML files download more quickly ”are optimized for download ”but an interpreter must parse them at run time to create instances of the classes described in the file. Therefore, such files are not optimized for speed. Up to now, I ve been generating compiled-to-IL files (also known as CAML files, short for compiled XAML).

Here s an example of a project file that creates an electronic document:

 <Project DefaultTargets="Build"> 
<PropertyGroup>
<Property TargetType="Document" />
<Property Language="C#" />
<Property DefaultClrNameSpace="IntroLonghorn" />
<Property TargetName="MyDocument" />
</PropertyGroup>

<Import Project="$(LAPI)\WindowsDocument.target" />

<ItemGroup>
<Item Type="ApplicationDefinition" Include="MyApp.xaml" />

<Item Type="Pages" Include="Markup.xaml" />
<Item Type="Pages" Include="Navigate.xaml" />
<Item Type="Code" Include="Navigate.xaml.cs"/>

<Item Type="Resources" Include="Picture1.jpg"
FileStorage="embedded" Localizable="False"/>
<Item Type="Resources" Include="Picture2.jpg"
FileStorage="embedded" Localizable="True"/>
</ItemGroup>
</Project>

Now that you ve learned how to build the various types of Longhorn applications and components , let s look at XAML files in more detail. Specifically, let s look at what the build system does when it turns a XAML file into a .NET class.




Introducing Microsoft WinFX
Introducing WinFX(TM) The Application Programming Interface for the Next Generation of Microsoft Windows Code Name Longhorn (Pro Developer)
ISBN: 0735620857
EAN: 2147483647
Year: 2004
Pages: 83
Authors: Brent Rector

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net