WPF Review Part 3 – Controls


Coming from a WF background, I was pleased to see that most of the standard controls are also available in WPF, such as Textboxes, Combos, Listboxes etc. However, as you might expect, it’s a not a direct like-for-like swap between the two worlds.

Firstly, there are a few controls which you’ll have used in WF that no longer exist out-of-the-box. Some are obsolete, like the Panel and Table control, which is no problem at all – the Grid and StackPanel etc. are superior to them anyway. However, some others, like the Numeric Up Down and Date Time Picker aren’t included. There are a few freely available controls that people have written that seem to do the trick, and I’ve been trying them out with varying degrees of success. Another omission is a DataGrid-esque control. I think what people are probably doing is to use existing WF grid controls within WPF applications. There are also a few commercial third-party control suites coming available – some look very impressive. But then again, the Infragistics website looks excellent too, and I’ve never been that impressed with what they offer.

By and large, by default the controls behave pretty much as per before for the simple situations etc.. Some of the property names are different e.g. IsEnabled instead of Enabled – but generally I have had no problem getting up to speed with these controls. There are also some nice new features, such as out-of-the-box databinding to ListViews and Treeviews (finally!).

The biggest difference between the way that the WF control set was designed and the WPF one is that WPF controls are “lookless” i.e. they contain a fixed set of behaviours, but a flexible and extensible presentation tier for the control. A simple example would be if you had an object which had two properties, Forename and Surname, and wanted to display both items in a ListBox. In the WF world you might have created a read-only property called Full Name or perhaps created an anonymous type for display purposes built on top of the two fields concatenated together. In WPF, you can now change what controls are used to display each item in the list e.g. in the example above, you might have two labels one after another, with the first displaying the forename and the second one displaying the surname. You can use this approach to create controls that are really just e.g. ListBoxes in terms of behaviour, but look nothing like them. Very cool.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s