BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Windows Presentation Foundation
.NET 4.0+

WPF Base Classes - ToggleButton

The seventy-fifth part of the Windows Presentation Foundation Fundamentals tutorial describes the base class for the CheckBox and RadioButton controls. ToggleButton includes the functionality required to identify the state of these toggleable controls.

ToggleButton

During the articles describing the WPF selection controls, we saw the CheckBox and RadioButton controls. These controls have are similar, in that they can be toggled between two or three states. Both controls can be either checked or unchecked, and the state can be obtained as a nullable Boolean value using the IsChecked property. A third state exists, known as the indeterminate state. By default, this state cannot be selected by the user but can be set from code or in the XAML for the control. However, if the IsThreeState property is set to true, it becomes possible to switch to this third value.

Both the IsChecked and IsThreeState properties are provided by the ToggleButton base class. Additionally, ToggleButton provides the three events that allow you to detect the change to a new state, these being Checked, Unchecked and Indeterminate.

As we've seen these properties and events in the earlier article, they will not be described again here.

30 June 2014