
Understanding the Role of XAML
Although XAML is a key aspect of WPF, few developers will need to author reams of XAML by hand
XAML, like any XML-based grammar, is verbose, tedious, and error prone. Numerous tools such as Visual
Studio and Expression Blend will generate XAML on your behalf as you make use of the tool itself.
Although it is true that WPF development tools will generate XAML in the background, it is important to
understand the basic syntax. This will allow you to tweak the generated XAML if the need should arise.
Also, XAML can be generated, loaded, parsed, and manipulated at runtime. To understand how to do so, a
working knowledge of XAML’s syntax is useful.
It is important to recall that XAML is a general-purpose markup language and is not limited to WPF. XAML
can also be found within the Windows Workflow Foundation API, where it is used to build custom activities
and workflows via markup. XAML is also used within Silverlight applications. XAML is also used by the
XML Paper Specification (XPS), a Microsoft technology for e-paper.
As detailed in your next lab, msbuild.exe uses XAML descriptions to generate intermediate code files used
during the compilation process. As a naming convention, these file have a ‘g’ infix (for generated). For
example, a XAML file named MyWindow.xaml will be used by msbuild.exe to generate a C# file named
MyWindow.g.cs or a VB file named MyWindow.g.vb. Within these generated files, you will find code-based
equivalents for various aspects of your XAML markup.
XAML files are also used to generate a compact binary form of the markup termed binary markup language
(BAML). By default, the BAML is embedded into your .NET assembly as a binary resource. At runtime, the
BAML is parsed to hydrate the state of your WPF objects (windows, applications, controls, and so on).
Because of BAML, you are seldom required to ship XAML files along with your compiled WPF application.
Unless you are dynamically loading external XAML files into memory, XAML files can be regarded as little
more than input to msbuild.exe.
Understanding the Role of XAML
Table of Contents
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials
Services