#384 – The Benefits of Flow-Based Layout
September 12, 2011 1 Comment
WPF provides several benefits by making flow-based layout a default.
This is not really a benefit of flow-based layout, but a benefit based on the fact that WPF specifies positions and sizes in device independent units, rather than in pixels. If the current DPI setting matches the native DPI of the device, then the actual size of the GUI elements will be as requested.
Controls Automatically Resized or Repositioned
Flow-based layout containers automatically reposition/resize child controls as the container is resized.
Controls Size to Fit Their Content
In WPF, you typically allow a control to size to fit it’s content. This removes the need for tweaking size and position of elements if the content changes.
<StackPanel> <Button Content="Bob" HorizontalAlignment="Center"/> <Button Content="John Jacob Jingleheimer Smith" HorizontalAlignment="Center"/> </StackPanel>
When controls size to fit their content, you don’t need to tweak layout for each localized language.