Prev | Current Page 264 | Next

Matthew MacDonald

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

(An autosized column would simply stretch to fit the text, making it larger
than the window.) The rows are set to automatic sizing, so they expand to fit the extra content.
Figure 5-11. Expanding in different directions
CHAPTER 5 n CONTENT 133
The Expander is a particularly nice fit in WPF because WPF encourages you to use a
flowing layout model that can easily handle content areas that grow or shrink dynamically.
If you need to synchronize other controls with an Expander, you can handle the
Expanded and Collapsed events. Contrary to what the naming of these events implies, they
fire just before the content appears or disappears. This gives you a useful way to implement
a lazy load. For example, if the content in an Expander is expensive to create, you might wait
until it??™s shown to retrieve it. Or perhaps you want to update the content just before it??™s shown.
Either way, you can react to the Expanded event to perform your work.
nNote If you like the functionality of the Expander but aren??™t impressed with the built-in appearance, don??™t
worry. Using the template system in WPF, you can completely customize the expand and collapse arrows so
they match the style of the rest of your application. You??™ll learn how in Chapter 15.
Ordinarily, when you expand an Expander it grows to fit its content.


Pages:
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276