Three states in WPF's CheckBox

Three states in WPF's CheckBox

CheckBoxControls and RadioButtonControls are inherited from ToggleButtonclasses, which means that users can toggle their switch states, where IsCheckedthe property is a nullable Boolean type, which means that the property can be set to true, false or null.

A null value represents an indeterminate state, showing a shaded checkbox, an indeterminate state is used to represent a value that has not been set

<CheckBox Content="testA"/>
<CheckBox IsChecked="{x:Null}" Content="testA" IsThreeState="True"/>

insert image description here

In addition to the IsChecked property, the ToggleButton class adds IsThreeStateproperties that determine whether the user can set the check box to an indeterminate state.

If the IsThreeState property is set to false (the default value), the stand-alone checkbox will toggle between checked and unchecked states.

If IsThreeState is set to true, the stand-alone check box will cycle through all three possible states.

Guess you like

Origin blog.csdn.net/weixin_47410172/article/details/132340018