Figure 4-23 shows a different permutation of
panels.
Figure 4-23. Hiding some panels
To hide and show the individual panels, a small bit of code handles check box clicks.
Although you haven??™t considered the WPF event handling model in any detail (Chapter 6 has
the full story), the trick is to set the Visibility property:
panel.Visibility = Visibility.Collapsed
The Visibility property is a part of the base UIElement class and is therefore supported by
just about everything you??™ll put in a WPF window. It takes one of three values, from the System.
Windows.Visibility enumeration, as listed in Table 4-5.
Table 4-5.Values of the Visibility Enumeration
Value Description
Visible The element appears as normal in the window.
Collapsed The element is not displayed and doesn??™t take up any space.
Hidden The element is not displayed, but the space it would otherwise use is still
reserved. (In other words, there??™s a blank space where it would have appeared).
This setting is handy if you need to hide and show elements without changing the
layout and the relative positioning of the elements in the rest of your window.
CHAPTER 4 n LAYOUT 116
nTip You can use the Visibility property to dynamically tailor a variety of interfaces. For example, you could
make a collapsible pane that can appear at the side of your window.
Pages:
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255