Applications = Code + Markup
A Guide to the Microsoft Windows Presentation Foundation

Charles Petzold


Applications = Code + Markup is an introduction to the Microsoft Windows Presentation Foundation (formerly code-named Avalon), the new programming interface for Windows applications. Approximately 1000 pages.

ISBN: 0-7356-1957-3; Microsoft Press; August 2006; 1002 pages.


This book is available from:

as well as many other real and virtual bookstores.

Source Code

For source code to programs in the book, go to the companion content page.

Source Code Translated to Visual Basic .NET

The book's source code has now been translated to Visual Basic .NET and can be downloaded here.

Using the Book

The Microsoft Windows Presentation Foundation (WPF) was officially released on November 6, 2006. To use the book, you will need to be running either Microsoft Windows Vista or Microsoft Windows XP with Service Pack 2 installed. You'll also need Visual Studio 2005.

Step 1. Install the .NET Framework 3.0 Redistributable Package (also known as the Runtime Components) from here. You do not need to do this step if you're running Windows Vista because the .NET Framework 3.0 is an intrinsic part of Vista.

Step 2. Install the .NET Software Development Kit from here. This is the big one! You can either download an ISO image to burn on a DVD, or run a Setup program that installs the SDK from the Web. The Web install is available here.

Step 3. Install the Visual Studio extensions for .NET 3.0 from here.

Step 4. My book specifies that you use the Empty Project option in Visual Studio. The .NET 3.0 extensions do not include an Empty Project option for WPF programming. To add this option, copy this file to the directory:

To create a new WPF empty project in Visual Studio, select the File | New Project item from the menu to display the New Project dialog. Select Visual C# at the left and then WPF Empty Project.

Errata List

Something doesn't look right? Check the Errata List. Errors are listed both by page number and in order of the date they're submitted to me.

Something definitely isn't right and it's not listed? Send me an email at

Historical Notes

What did The Windows Presentation Foundation look like back in 2003? Check out Charles Petzold's article "Code Name Avalon: Create Real Apps Using New Code and Markup Model" from the January 2004 issue of MSDN Magazine.

What was like writing a thousand page book in ten months? The Petzold Book Blog began with this entry as I was finishing one book and about to begin another.

Installable Executables

These executables run under Release Candidate 1 of Microsoft Windows Vista, or the .NET 3.0 Framework installed under Windows XP.

XAML Cruncher

XAML Cruncher lets you interactively type XAML code and see the object it creates. The program has all the features of Windows Notepad (including File Open and Save dialog boxes, printing, and a font dialog) and customization features. This program is installable through the .NET ClickOnce facility.


ClockStrip displays multiple clocks in a horizontal or vertical strip, each one configurable to display the current time for a city of your choice. This program is installable through the .NET ClickOnce facility.



YellowPad is a rudimentary Tablet PC application that mostly just demonstrates the InkCanvas API. The pad has only one page that you can draw on using the sylus or the mouse. Help information built around FlowDocument objects is available.

One interesting aspect of the YellowPad program is that it lets you save ink as a Drawing object in XAML format. See this blog entry for details.

Browser Applications

The following programs were compiled as "XAML Browser Applications." The executables have a filename extension of .XBAP and require Release Candidate 1 of the .NET Framework 3.0, which can be installed from here. These XAML Browser Applications are restricted "partial trust" applications that run in your Web browser with their own back and forward navigation buttons at the upper-left corner of the page.

Hybrid Clock

A hybrid analog/digital clock that displays the date and time as a sweep second hand. Right click for a context menu that lets you change the date/time format.

Jeu de Tacquin

A realization of the famous "14-15 Puzzle" written for the Windows Presentation Foundation. Besides a mouse interface, the Jeu de Tacquin program also includes a keyboard interface using the arrow keys. Be sure to try out the 'Next Larger' button!

© Charles Petzold, 2008
This page last updated May 2008