Category Archives: Windows Presentation Foundation

Update to "Taking the WPF Plunge"

Just a quick note, I made two updates to Monday’s post on Taking the WPF Plunge (, one clarified a point and the second added one more download item you may want. If you’ve already read it, please go take a quick look at the updates.



XAML is the definition language most often used to define a WPF based user interface. Using XAML you can define sleek, modern and highly functional applications.

Most people talk about XAML and WPF interchangeably, but I feel I need to kick off our discussion with an important concept:


XAML and WPF are, in fact two separate things even if they are closely linked. XAML is a definition language, similar to HTML. Well, more like HTML, WINForms and XML collided together in a Mythbusters type of explosion, and XAML is the result.

XAML requires a framework to execute. Often that framework is WPF, but it’s not necessarily so. Internet Explorer can interpet and display a XAML page, as can tools like XamlPad. Take this simple example:

<Page xmlns=”; xmlns:sys=”clr-namespace:System;assembly=mscorlib” xmlns:x=”; >
<Label>Welcome to ArcaneCode!</Label>

Here you can see XamlPad displays the label in the upper part of the window:


No WPF, no compilation, no other magic, just the XAML Parser at work. You could save the code snippet above, and open it in Internet Explorer if you so wished.

Now let’s create another user interface, this time we’ll use WPF and NO XAML! Start a new project in Visual Studio, and pick BlankProject (note, do NOT pick Windows Project (WPF). We’ll use it later, but not today.)

Add references to three assemblies in the .Net tab: PresentationCore, PresentationFramework, and WindowsBase.

Now add a class, I named mine wpftest. Here’s my code:

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows;

using System.Windows.Controls;


namespace wpf001


  class wpftest : Application



    static void Main()


      wpftest mytest = new wpftest();

      mytest.Startup += MyTestStartup;




    static void MyTestStartup(object sender, StartupEventArgs e)


      arcaneWindow aw = new arcaneWindow();





Note the use of an arcaneWindow class, let’s create that now:

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows;

using System.Windows.Controls;


namespace wpf001


  class arcaneWindow : Window


    Label lblWelcome = new Label();


    public arcaneWindow()


      this.Title = “Greetings!”;

      this.Width = 320;

      this.Height = 120;


      lblWelcome.Content = “Welcome to ArcaneCode!”;





Note the following things:

First, I’ve added two “using” lines, System.Windows and System.Windows.Controls. Next, I needed to create a new window (arcaneWindow) and inherit from the base Window type. Finally, I created a WPF label control, and added it to our window via AddChild.

Once you get all of it in, run the program and you should see:


There you go, you’ve just created a WPF user interface without a single line of XAML.

My point of this kick off was to demonstrate the difference between WPF and XAML. Most times, you will probably be using WPF and XAML in conjunction, but you don’t HAVE to.

In the coming days, we’ll delve a little deeper, and I’ll explain more of what some of the code you’ve seen today means.

WPF Resources

Yesterday I pointed out where to download all the bits you need to get into WPF. Today I thought I’d share some good resources on learning WPF.

First off is Todd Miranda’s site Xperimentality . Todd is an MVP and has done many of the videos that appear on the Windows Client site.

Speaking of the WindowsClient.Net site, you can find many of those videos at , just scroll down to the WPF area.

Todd Miranda’s videos on the Expression suite can be found on the Expression Knowledge Center site, . There are also videos by others.

Channel 9 has now reached 100 items on WPF:

Mark Miller recently did a DNRTV episode on Custom Controls in WPF, find it at . Also on DNRTV, Brian Noyes did a two parter on WPF, found here and here .

Another great blog is Lester’s WPF Blog, . Lots of good stuff from the author of XAMLPadX, which I recommended yesterday.

Finally, a book recommendation, I’m finding Adam Nathan’s book on WPF to be a really good read. It’s more than technical enough to keep an experienced reading, and all of the code samples are in color!

Taking the WPF Plunge

I wrote earlier that I felt WPF and XAML were the UI design platform of the future ( ). I’ve decided to put my time where my (some would say big) mouth is, and devote some time to learning WPF. In case you want to come along for the ride, lets look at what you need to get started.

First, you need the .Net Framework 3.0. Odds are you already have it, if you have Vista you definitely have it. If you are still on XP, and haven’t downloaded it grab your copy from . Make sure your XP has been patched with Service Pack 2.

That’s it, that’s all you have to have. However there are some things that will make your life easier. Visual Studio 2005, for example. Odds are if you read this blog you already have a version, but if not grab one from . You’ll want to select Windows Development, and pick either C# or VB.Net.

Finally, you’ll want the Windows Software Development Kit. The Windows SDK contains a very useful tool called XamlPad, which you can use to quickly test your XAML code. The Vista version is at . UPDATE (Aug 15): I should have been a little more awake when I wrote this. Even though the download has Vista in the title, the SDK will actually install and run on Windows XP (with SP2) and Server 2003 in addition to Vista.

If you’re on XP, or want something other than the SDK check out XamlPadX at .

Finally, if you are lucky enough to have an MSDN Subscription, take a look at Expression Blend and Expression Web, I’ll be looking at them later.

There, that ought to keep you busy for a bit!

UPDATE UPDATE (Aug 16th)Well I did it again. When I posted the Aug 15th update (at the bottom) I grabbed the wrong text and pasted it in. Obviously, the Workflow Foundation extensions don’t do you any good when you want to work with WPF. Instead I meant to refer you to the extensions for WPF & WCF at . Don’t let the fact that it reads CTP shake you, this is the last release for VS2005, Microsoft decided to make all further updates to the VS2008 product. The bits work fine though, and add templates so you can create WPF/WCF projects.

One note, when you go to install this extension, it will first recommend you have the Windows SDK (see link earlier in this message) installed. Second, it will recommend you set your help in Visual Studio 2005  to use local instead of on-line as the primary source. Just be aware of these two quirks.

I’ll leave the Workflow link below active though, it won’t hurt to install it, and you might want to dive into WF at some point.

UPDATE (Aug 15th): One more item you’ll want if you intend to use Visual Studio, you’ll want the Extensions for Windows Workflow Foundation, which you’ll find here . (It’s only a 6 mb download, so it shouldn’t take long.)