|Visual C# Tutorials|
|.NET Framework Tutorials|
|© 2007 Matthew MacDonald|
|This tutorial—XAML—is from Pro WPF: Windows Presentation Foundation in .NET 3.0, by Matthew MacDonald. Copyright © 2007 Matthew MacDonald. All rights reserved. This article is reproduced by permission. This tutorial has been edited especially for C# Online.NET. Read the book review!|
XAML (short for Extensible Application Markup Language, and pronounced "zammel") is a markup language used to instantiate .NET objects. Although XAML is a technology that can be applied to many different problem domains, its primary role in life is to construct WPF user interfaces. In other words, XAML documents define the arrangement of panels, buttons, and controls that make up the windows in a WPF application.
It’s unlikely that you’ll write XAML by hand. Instead, you’ll use a tool that generates the XAML you need. If you’re a graphic designer, that tool is likely to be a graphical design and drawing program such as Microsoft Expression Blend. If you’re a developer, you’ll probably start with Visual Studio. Because both tools are equally at home with XAML, you can create a basic user interface with Visual Studio and then hand it off to a crack design team that can polish it up with custom graphics in Expression Blend. In fact, this ability to integrate the workflow between developers and designers is one of the key reasons that Microsoft created XAML.
In this chapter, you’ll get a detailed introduction to XAML. You’ll consider its purpose, its overall architecture, and its syntax. Once you understand the broad rules of XAML, you’ll know what is and isn’t possible in a WPF user interface—and how to make changes by hand when it’s necessary. More importantly, by exploring the tags in a WPF XAML document you can learn a bit about the object model that underpins WPF user interfaces and get ready for the deeper exploration to come.
Note Currently, WPF developers need to write more than a little XAML by hand because the WPF extensions for Visual Studio 2005 aren’t terribly sophisticated. They’re able to show a graphical representation of the WPF windows you create, but they don’t offer a true drag-drop-and-configure design experience. Future versions of Visual Studio (which were in early beta at the time of this writing) will offer far superior design support.