Add Check Boxes (Radio Buttons) Next to Each Item
This tutorial demonstrates how to take advantage of the built-in CheckBox support in the RadTreeViewItems.
RadTreeView provides check boxes displayed next to each item. Enable this behavior by setting the IsOptionElementsEnabled property of the RadTreeView to True.
To handle the change of the item check state use the PreviewChecked, Checked, PreviewUnchecked and Unchecked events. These events are available both on the RadTreeView and on the RadTreeViewItem classes.
To see the Item check state use the CheckState property of the RadTreeViewItem class. The CheckState property is a ToggleState enumeration and has the following values:
- On - the Item is checked.
- Off - the Item is not checked.
- Indeterminate - the Item has items that are checked and items that are not checked. This state is available only when the RadTreeView IsTriStateMode property is set to True.
If the check boxes need to have "tri-states" set the IsTriStateMode property of the RadTreeView to True. When this mode is activated the CheckState property of each item is depending on the CheckState property of its child items. In this mode the item will be checked only if all of its child items are checked too.
Please keep in mind that the RadTreeView 'tri-state' check boxes logic is desined to work in declaratively populated RadTreeView control. This is why if your applicaiton implements an MVVM approach and the RadTreeView is databound, it's best to define custom 'tri-state' logic in your ViewModels following this tutorial.
For more information, read the topic about CheckBox Support.