Prev | Current Page 186 | Next

Matthew MacDonald

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


Developers can now create resolution-independent, size-independent interfaces that scale
well on different monitors, adjust themselves when content changes, and handle the transition
to other languages effortlessly. However, before you can take advantage of these changes,
you??™ll need to start thinking about layout a little differently.
The WPF Layout Philosophy
A WPF window can hold only a single element. To fit in more than one element and create a
more practical user interface, you need to place a container in your window and then add
other elements to that container.
nNote This limitation stems from the fact that the Window class is derived from ContentControl, which
you??™ll study more closely in Chapter 5.
In WPF, layout is determined by the container that you use. Although there are several
containers to choose from, the ???ideal??? WPF window follows a few key principles:
??? Elements (like controls) should not be explicitly sized. Instead, they grow to fit their
content. For example, a button expands as you add more text. You can limit controls
to acceptable sizes by setting a maximum and minimum size.
??? Elements do not indicate their position with screen coordinates. Instead, they are
arranged by their container based on their size, order, and (optionally) other information
that??™s specific to the layout container.


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