#383 – The Problems with Coordinate-Based Layout
September 9, 2011 1 Comment
WPF uses flow-based layout by default (e.g. StackPanel and Grid containers), with coordinate-based layout as an option (e.g. Canvas).
At first glance, coordinate-based layout seems easier. You can position and size every control exactly how you want it to look. Flow-based layout can be a little frustrating, as you try to get a container to organize its child controls the way that you want.
But coordinate-based layout has some limitations:
- Controls look different, depending on the resolution of the display device (e.g. get smaller on higher DPI devices)
- If you allow resizing a window or any area within a GUI (e.g. with a splitter) you have to do a lot of work to resize or reposition the controls as the container changes size
- Controls don’t automatically resize or re-position to fit their content
- Controls don’t automatically resize or re-position to accommodate non-English text