Prev | Current Page 373 | Next

Matthew MacDonald

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


The CheckBox
Both the CheckBox and the RadioButton are buttons of a different sort. They derive from
ToggleButton, which means they can be switched on or off by the user, hence their ???toggle???
behavior. In the case of the CheckBox, switching the control ???on??? means placing a check mark
in it.
The CheckBox class doesn??™t add any members, so the basic CheckBox interface is defined
in the ToggleButton class.Most important, ToggleButton adds an IsChecked property.
IsChecked is a nullable Boolean, which means it can be set to True, False, or a null reference
(Nothing). Obviously, True represents a checked box, while False represents an empty one. The
Nothing value is a little trickier??”it represents an indeterminate state, which is displayed as a
shaded box. The indeterminate state is commonly used to represent values that haven??™t been
set or areas where some discrepancy exists. For example, if you have a check box that allows
you to apply bold formatting in a text application and the current selection includes both bold
and regular text, you might set the check box to Nothing to show an indeterminate state.
To assign a null value in WPF markup, you need to use the null markup extension, as
shown here:
A check box in indeterminate state
Along with the IsChecked property, the ToggleButton class adds a property named
IsThreeState, which determines whether the user is able to place the check box into an indeterminate
state.


Pages:
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385