Prev | Current Page 187 | Next

Matthew MacDonald

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

If you need to add whitespace between
elements, you use theMargin property.
nTip Hard-coded sizes and positions are evil because they limit your ability to localize your interface, and
they make it much more difficult to deal with dynamic content.
??? Layout containers ???share??? the available space among their children. They attempt to
give each element its preferred size (based on its content) if the space is available. They
can also distribute extra space to one or more children.
??? Layout containers can be nested. A typical user interface begins with the Grid, WPF??™s
most capable container, and contains other layout containers that arrange smaller
groups of elements, such as captioned text boxes, items in a list, icons on a toolbar, a
column of buttons, and so on.
79 CHAPTER 4 n LAYOUT
Although there are exceptions to these rules, they reflect the overall design goals of WPF.
In other words, if you follow these guidelines when you build a WPF application, you??™ll create
a better, more flexible user interface. If you break these rules, you??™ll end up with a user interface
that isn??™t well suited to WPF and is much more difficult to maintain.
The Layout Process
WPF layout takes place in two stages: a measure stage and an arrange stage. In the measure
stage, the container loops through its child elements and asks them to provide their preferred
size.


Pages:
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199