Learn WPF by example (a recipe)

Ever wonder how the experts build clever things into their WPF applications? Here’s one way to find out which uses a few of my favourite tools for building WPF and Silverlight apps.

Required Ingredients:

1. Snoop, an excellent utility that lets you visualize and probe a running WPF application.

2. Lutz’s tried and true Reflector utility, which lets you view, navigate, search, decompile and analyze .NET assemblies in C#, Visual Basic and IL.

3. A WPF application that you’d like to learn from. For example, Expression Blend 2, which is used for making WPF applications and was also made with WPF itself. (More examples follow :) )


0. Add the assemblies (.DLL and .EXE files) from the interesting WPF application into Lutz’s Reflector.

1. Run the WPF application that you’d like to learn from. As an example, run Expression Blend, and ponder how they make those nice search textboxes with the word “Search” greyed out behind your text. (I know, they’re actually pretty simple – this is just an example)

2. Run Snoop to peer in on the WPF process. In this case, Blend itself.

3. Hold down Ctrl-Shift while mousing over the element that you’d like to learn about. In this example, discover with Snoop that what you’re looking for here is a custom control of Type OverlayTextBox.

4. In Reflector, look up the Type you’d like to better understand. In this example, just search for OverlayTextBox, and discover it’s a TextBox with a few extra DependencyProperties and Methods.

5. Learn by expert example.

Here are some other apps you might want to spelunk using this technique. For these two, the source is also available, which can make for an even more thorough investigation.

Kevin Moore’s WPF Bag of Tricks – an expertly-constructed set of samples from Kevin Moore, a former member of the WPF team.

Avalon Healthcare Monitoring Demo – the medical dashboard demo I showed at the O# VS2008 at the Movies Event. Built in the WPF 3.0 era but still an excellent learning resource.

WPF Training

Speaking of learning WPF: you may be interested in the hands-on WPF training course offered through my consultancy, Carrington Technologies. Please see here for more information.

WPF Training Course


Comments are closed.