Grouping Checkboxes

All the benefits of a radio button with the three "state-ness" of a checkbox and the layout flexability of WPF

 

If you have done any with WPF radio buttons you know that WPF has given us greater flexibility to define radio groups. In WinForms radio button groups were constrained to the parent panel. This meant if you wanted radio buttons to be mutually exclusive, that is you can only have one selected at a time, they all had to live within the same parent layout panel.

In WPF you don’t have this limitation, when you specify a group name for a radio button it will be mutually exclusive to any other radio button that has the same group name within the visual tree. This gives you greater flexibility with how you layout your radio groups.

The problem is you can’t “un-select” a radio button once it has been checked. I set out to find a solution that would give me mutual exclusivity and the ability to have an unchecked state for my entire group, that is nothing in the group is selected.

Enter the grouping checkboxes. What I wanted was the check / uncheck behavior of checkbox (really of the base toggle  button) with the functionality of a radio button.

 

For further reading see my blog post here: http://www.bradcunningham.net/2009/09/grouping-and-checkboxes-in-wpf.html

 

(This is the most requested page on my blog and my most requested sample so I am publishing it here for the communities use)