I like WPF


WPF is a graphical subsystem for rendering user interfaces, first introduced in .NET Framework 3.0. It provides you with a fully featured alternative to Windows Forms which, let’s be honest, is old and hideous. It supports all kinds of cool things but we won’t go into those right now, I just want to tell you what I think of WPF as it currently stands.

I think it’s great. This might be an unpopular opinion – people have expressed that creating an application in WPF is slower and more tedious than in Windows Forms. While I see their reasoning, the feature set of WPF is enough to win me over. Let’s start with the biggest one for me;

XAML & styling

Styling is an absolute dream. You can customise every single pixel in a relatively easy way (once you get used to it) and the available panels (grids, stack panels, etcetera) make it easy to organise and manage your controls. WPF uses XAML to express layout and style (just like Silverlight by the way) which I think works fine. In XAML you have the ability to define templates, controls, etcetera and use them elsewhere whether that is the same file, or another control or even another window. Then in your source file (named the same as the XAML file usually) you define events (wired up from XAML) and other behaviours.

To give you an example of how styling (and XAML) works; consider the following example:

This bit applies a custom style to a ListBox item. Based on the triggers it is setting the background of the Border element to White (default was transparent) only if the listbox item has been selected. Once unselected, the trigger ‘IsSelected’ will become false, and the Background value ‘White’ will be unset – meaning it goes back to what it was before (transparent in this case). This bit is not meant to explain you the fine inner details of WPF, rather it is showing you how XAML looks.

Some would argue this is quite a big piece of XAML for something as simple as setting the selection background of a listbox item. I tend to agree but this is the nature of XAML – it is extremely abstract. Any type of Trigger (DataTrigger, MultiTrigger, …) can be added to the ControlTemplate.Triggers. Any type of Template can be added to ControlTemplate. And type of Setter can be added to Style, and so on. This offers an extreme amount of flexibility but you might lose a bit of brevity. Oh well.


Second bit is binding. WPF supports all kinds of bindings but most people will use bindings in a few simpler ways. Consider the following example:

(PS: This example does not work, it’s meant as pseudocode)
The simplest type of binding is used here; a property binding. If you add a simple object to a listbox (can be anything, a C# ‘object’ or a dynamic), this item will try to find the property ‘Text’ on whatever that object is.

The result would be that two items are added with the text ‘Testing’ and ‘My listbox item!’. The big thing is the ListBox item can really contain any control! An Image, a dropdown, a checkbox, heck even a webview, and you can set the properties by using the {Binding}s.

If it cannot resolve a binding it will be empty. If it can resolve the property but it is not of the correct type, it will use  ToString() .

This is just one example of bindings, others are using StaticResources and such but that is of no importance right now.

Who or what’s using WPF?

Visual Studio 2010 is a great example of a good WPF app. Autodesk AutoCAD uses it for the Ribbon control. SourceTree uses it. Yahoo Messenger, Expression Blend, PowerShell ISE all use it.

To be quite honest, WPF hasn’t really caught on that widely and Microsoft is moving to the UWP (Universal Windows Platform). Nevertheless, WPF is still widely used in (custom) business applications as a replacement for Windows Forms and it’s doing its job. It is still receiving updates from Microsoft and I think it’ll be usable for at least the coming 5 years. After that, we’ll see how UWP is doing.




Universal Windows Platform is a new direction Microsoft is taking applications. It is created to be, as the name implies, universal so your apps work on Xbox, Windows Phones, Windows tablets and desktops. The idea is fine to me, but they had to use the bad new UI design (in Windows 10, open ‘Settings’ and click an option). I think for example Outlook’s 2016 UI is much better. It feels like they inadvertently created a rift between UI design. You have the ‘Windows Store’ apps like ‘Mail’ and then you have Outlook 2016. Both use a relatively new UI, but Outlook’s feels much more refined albeit a little more advanced. I have the feeling I’m constantly looking for an something in the ‘new’ Windows Store apps – probably because it is literally ‘cleaner’ so it has less UI controls (less options).

I don’t know if it will catch on. I’m kind of hoping it won’t.

Leave a comment

Your email address will not be published. Required fields are marked *