Prev | Current Page 204 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

As this example demonstrates,
a WrapPanel in horizontal mode creates a series of imaginary rows, each of which is
given the height of the tallest contained element. Other controls may be stretched to fit or
aligned according to the VerticalAlignment property. In the example on the left in Figure 4-8,
all the buttons fit into one tall row and are stretched or aligned to fit. In the example on the
right, several buttons have been bumped to the second row. Because the second row does not
include an unusually tall button, the row height is kept at the minimum button height. As a
result, it doesn??™t matter what VerticalAlignment setting the various buttons in this row use.
CHAPTER 4 n LAYOUT 89
Figure 4-8.Wrapped buttons
nNote The WrapPanel is the only panel that can??™t be duplicated with a crafty use of the Grid.
The DockPanel
The DockPanel is a more interesting layout option. It stretches controls against one of its
outside edges. The easiest way to visualize this is to think of the toolbars that sit at the top of
many Windows applications. These toolbars are docked to the top of the window. As with the
StackPanel, docked elements get to choose one aspect of their layout. For example, if you dock
a button to the top of a DockPanel, it??™s stretched across the entire width of the DockPanel but
given whatever height it requires (based on the content and the MinHeight property).


Pages:
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216