WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 479 reviews for our classroom and online training
Why you should develop systems in WPF, not WinForms
Part three of a eleven-part series of blogs

We think - cautiously - that WPF is a better platform for client tool development than Windows Forms. This blog gives 10 reasons why.

  1. 10 reasons why WPF is better than Windows Forms
  2. WPF Forms are Quicker to Create
  3. Flow Layout Trumps Absolute Positioning (this blog)
  4. WPF Works for Websites
  5. Styles are Much Better in WPF
  6. WPF is (I think) the Way of the Future
  7. Better Data Binding
  8. Selecting Controls in the Document Outline Window
  9. Triggers
  10. StoryBoards and Animations
  11. Drawing!

Posted by Andy Brown on 25 September 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.

2 - Flow Layout Trumps Absolute Positioning

It took me a long time to convince myself that this is true, but I'm now a convert.  Let's look at how the two systems deal with layout.

Windows Forms uses Absolute Positioning

Consider our OK button:

An OK button on a form

The reason that this button is where it is isn't because it's pushed down by the controls above it; it's because it's X and Y position give the absolute distance of the button from the top left of the form.


WPF uses Relative Positioning

By contrast, have a look at the WPF form:

OK button in WPF form

The reason the OK button is where it is is that a horizontal stack panel lies above it, and it's the first control in a second centrally aligned horizontal stack panel!


The XAML for the window shows this slightly more clearly:

The XAML for a form

The OK button is shown selected.

Why Flow Layout is Better

For simple forms like the above, I can just about accept that absolute positioning is quicker - but most forms aren't this simple.  Consider this window containing a Top Trumps card:

A Top Trumps card window

The great thing about relative layout is that you can resize a window without worrying about the contents.  Here the window consists of (vertically, from top to bottom):


WPF forms behave like websites in the way they flow down and across the screen or page - which brings me on to my next advantage.

This blog has 0 threads Add post