#853 – A CheckBox Can Always Be in an Indeterminate State

If you set the IsThreeState property of a CheckBox to true, the user can cycle the CheckBox through three states, rather than true–checked, not checked and indeterminate.

<CheckBox Content="I cycle through 3 states" IsThreeState="True"/>

853-001
853-002
853-003
If the IsThreeState property is set to false, the user can only cycle the CheckBox through the checked and unchecked states.  You can, however, still set the CheckBox to an indeterminate state using data binding or from code.

        <CheckBox Name="chkTest" Content="I cycle through 2 states" IsThreeState="False"/>
        <Button Content="Set Indeterminate" Click="Button_Click" Margin="15"/>

</span>
<pre>        private void Button_Click(object sender, RoutedEventArgs e)
        {
            chkTest.IsChecked = null;
        }

853-004

Advertisement