Windows Forms or WPF ? Choosing software.
Part two of a three-part series of blogs

If you're developing software, should you use old-fashioned but reliable WinForms, or the exciting new concept, WPF?

  1. Windows Forms or WPF?
  2. WinForms or WPF from the Developer's Point of View (this blog)
  3. WinForms or WPF - from a Project Manager's Viewpoint

Posted by Andy Brown on 23 March 2012

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

WinForms or WPF from the Developer's Point of View

If you're a programmer starting a new project, I think I'd go for WPF: you'll learn a new technology, and you'll probably have more fun.  Let's take an example of a humble label.

Label in WPF

The label below was created in WPF:

A coloured label

The label has a reflected gradient effect.

 

Here's the XAML to display this label (XAML is the language in which WPF applications are written):

The XAML for a label

The label includes settings for its fill colour and its border.

You can set linear and radial gradient effects, fill the label with an image (with bevelled or faded edges) or even set a transform effect so that the label is rotated or skewed.

A Label in Windows Forms 

The label below was created in WinForms:

A label with back colour

A basic label in WinForms, with background colour set.

 

You can see how this was created in Visual Basic (or C# - not shown here), but normally you'd edit the label in design view as above.

An Example Form from WPF 

All WPF forms use flow layout: the next element on a form is positioned, usually, underneath or next to the previous one (by contrast WinForms uses absolute positioning throughout: controls display exactly where you put them).

To see how the WPF version works, consider this form (or window, as I should more properly call it):

A Top Trumps card

A Top Trumps card designed in WPF

Here is the outline for this window:

Document outline for window

This is called the Document Outline window. It allows you to see how elements are nested within each other.

 

The above shows that to apply a border round something in WPF, you include it in a Border control. 

Recommendation if you're a Developer

If you're having to create an application, you can have great fun with transforms, animation effects and gradient patterns.  You can create styles to apply to different types of control, and resources to share elements (or parts of elements between forms).

Now let's have a look at it from the perspective of a project manager ...

 

  1. Windows Forms or WPF?
  2. WinForms or WPF from the Developer's Point of View (this blog)
  3. WinForms or WPF - from a Project Manager's Viewpoint
This blog has 0 threads Add post