Prev | Current Page 231 | Next

Matthew MacDonald

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

) If you don??™t set the Width and Height properties,
your element will get its desired size??”in other words, it will grow just large enough to
fit its content.
Here??™s a simple Canvas that includes four buttons:






Figure 4-17 shows the result.
CHAPTER 4 n LAYOUT 107
Figure 4-17. Explicitly positioned buttons in a Canvas
If you resize the window, the Canvas stretches to fill the available space, but none of the
controls in the Canvas moves or changes size. The Canvas doesn??™t include any of the anchoring
or docking features that were provided with coordinate layout in Windows Forms. Part of
the reason for this gap is to keep the Canvas lightweight. Another reason is to prevent people
from using the Canvas for purposes for which it??™s not intended (such as laying out a standard
user interface).
Like any other layout container, the Canvas can be nested inside a user interface. That
means you can use the Canvas to draw some detailed content in a portion of your window,
while using more standard WPF panels for the rest of your elements.


Pages:
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243