Layout controls determine the arrangement of the controls that they contain. For example, they may arrange controls vertically, horizontally, or in rows and columns.
The preferred style for WPF control arrangement is to make container controls determine the positions of their children and let the children take advantage of whatever space is allowed. This can be particularly useful for localized applications where you cannot easily predict how much space a control will need in a particular language.
For example, suppose a form contains a StackPanel control. The StackPanel contains several buttons that launch application dialog boxes. If you remove the buttons’ Width properties, the buttons automatically size themselves to fit the StackPanel horizontally. Now if you need to make the buttons wider to hold text for a new language, you can simply widen the form. The StackPanel widens to fill the form and the buttons widen to fit the StackPanel.
Example program ResizingButtons, which is available for download on the book’s website, demonstrates buttons with fixed heights but widths that resize when their container resizes.
Layout controls are also important because they can hold lots of other controls. Some of the WPF controls can hold only a single content item. For example, an Expander can hold only a single item. However, if you place ...