"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"
You can also allow a window to resize itself in just one dimension by using a SizeToContent value of Width or Height. CHAPTER 4 n LAYOUT 88 The WrapPanel and DockPanel Obviously, the StackPanel alone can??™t help you create a realistic user interface. To complete the picture, the StackPanel needs to work with other more capable layout containers. Only then can you assemble a complete window. The most sophisticated layout container is the Grid, which you??™ll consider later in this chapter. But first, it??™s worth looking at the WrapPanel and DockPanel, which are two more of the simple layout containers provided by WPF. They complement the StackPanel by offering different layout behavior. The WrapPanel The WrapPanel lays out controls in the available space, one line or column at a time. By default, the WrapPanel.Orientation property is set to Horizontal; controls are arranged from left to right, and then on subsequent rows. However, you can use Vertical to place elements in multiple columns. nTip Like the StackPanel, the WrapPanel is really intended for control over small-scale details in a user interface, not complete window layouts. For example, you might use a WrapPanel to keep together the buttons in a toolbar-like control. Here??™s an example that defines a series of buttons with different alignments and places them into the WrapPanel:
Figure 4-8 shows how the buttons are wrapped to fit the current size of the WrapPanel (which is determined by the size of the window that contains it).