Prev | Current Page 196 | Next

Matthew MacDonald

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


This list of properties is just as notable for what it doesn??™t contain. If you??™re looking for
familiar position properties, such as Top, Right, and Location, you won??™t find them. That??™s
because most layout containers (all except for the Canvas) use automatic layout and don??™t
give you the ability to explicitly position elements.
Alignment
To understand how these properties work, take another look at the simple StackPanel shown
in Figure 4-2. In this example??”a StackPanel with vertical orientation??”the VerticalAlignment
property has no effect because each element is given as much height as it needs and no more.
However, the HorizontalAlignment is important. It determines where each element is placed
in its row.
Ordinarily, the default HorizontalAlignment is Left for a label and Stretch for a Button.
That??™s why every button takes the full column width. However, you can change these details:







Figure 4-4 shows the result. The first two buttons are given their minimum sizes and
aligned accordingly, while the bottom two buttons are stretched over the entire StackPanel.


Pages:
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208