
Understanding the Role of XAML
Although XAML is a key aspect of Silverlight, 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 Silverlight 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 Silverlight. As
noted earlier in this chapter, XAML is also within WPF applications. XAML can also be found within the
Windows Workflow Foundation API (WF), where it is used to build custom activities and workflows via
markup. XAML is also used by the XML Paper Specification (XPS), a Microsoft technology for e-paper.
Although WPF, WF, XPS and Silverlight all use XAML, be aware that the related schema is not identical!
Therefore, don’t be too surprised if you attempted to copy a WPF XAML description into a Silverlight
project, and need to adjust the markup. As a good rule of thumb, consider Silverlight XAML to be a subset of
WPF XAML.
As detailed in your next lab, Visual Studio 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 Page.xaml will be used to generate a C# file named Page.g.cs or a VB file
named Page.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 (UserControls, applications, controls, and so on).
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