WPF Layouting Essentials

Wire-Frame

  • First rule of layouting : Do not explicitly set Width and Height for resizable control containers.
  • Second rule of layouting : Do not explicitly set Width and Height for resizable control containers.
  • Third rule of layouting : Set MinWidth/MinHeight pair and/or MaxWidth/MaxHeight pair instead.
  • Fourth rule of layouting : Use set Main Container Window SizeToContent property and the third rule as base layout.

About First and Second Rule

Enough Fight Club gibberish, setting width and height of a control explicitly on a container control will render the container control static. Static control does not follow the resizing of its container control. This can be a problem when you want to have a container panel to follow the parent when the parent is resized by user / code. This intended behavior is the same as Winform's Dock.Fill control property.

About Third Rule

Setting minimum size and maximum size allows developer programming paradigm to be less static and more scalable by means of user interface.

About Fourth Rule

Using the SizeToContent property to the predefined setting (application dependent) ensures all main window contents to be as visible as possible.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License