BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
We think - cautiously - that WPF is a better platform for client tool development than Windows Forms. This blog gives 10 reasons why.
- 10 reasons why WPF is better than Windows Forms
- WPF Forms are Quicker to Create
- Flow Layout Trumps Absolute Positioning (this blog)
- WPF Works for Websites
- Styles are Much Better in WPF
- WPF is (I think) the Way of the Future
- Better Data Binding
- Selecting Controls in the Document Outline Window
- Triggers
- StoryBoards and Animations
- 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:

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:

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 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:

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.
- 10 reasons why WPF is better than Windows Forms
- WPF Forms are Quicker to Create
- Flow Layout Trumps Absolute Positioning (this blog)
- WPF Works for Websites
- Styles are Much Better in WPF
- WPF is (I think) the Way of the Future
- Better Data Binding
- Selecting Controls in the Document Outline Window
- Triggers
- StoryBoards and Animations
- Drawing!