Silverlight/WPF: When do I want a 3-state CheckBox?

The answer is : probably not very often. Setting the IsThreeState property of a CheckBox control to True enables the user to click through all three states (unchecked, indeterminate, checked), but that is rarely what you want. You might do this for a survey, with yes/no/unsure choices, but I doubt most users would even pick up on the mechanism. You’d be better off with radio buttons. More often than not what you want that third state for is to show that some but not all of a parent’s child items are checked. In other words, the parent’s check state is checked if all its children are checked, unchecked if all its children are unchecked, and indeterminate otherwise.

The logic for this is going to go into some code-behind, or in the accessor methods for a data item property. It is not something the user should control. Fortunately, the IsThreeState property of a CheckBox control has no effect on its ability to display three states. It only affects the response to user actions. So in this scenario what you want is a normal 2-state CheckBox, and then when a parent meets the criteria for being indeterminate you’ll set its IsChecked property to null. It’s as simple as that. To see what I mean copy-paste the following into XamlPad:

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<CheckBox x:Name="CheckBox1" Content="I'm a 2-state CheckBox">
		<CheckBox.IsChecked><x:Null /></CheckBox.IsChecked>
	</CheckBox>
</Grid>

As you can see, setting the 2-state CheckBox’s IsChecked property to null causes it to display the third, indeterminate state. There’s no need for IsThreeState to be true for most scenarios where CheckBoxes are used.