Checkbox Elements
The TreeView for .NET MAUI allows you to show checkbox elements and check specific items from its ItemsSource
. The checked items are added to the CheckedItems
property of the control. You can also control the visibility of the checkbox elements as well as their state propagation.
Checkbox State Propagation
You can control the state propagation by setting the CheckBoxMode
property (enum of type Telerik.Maui.Controls.TreeView.TreeViewCheckBoxMode
). The TreeViewCheckBoxMode
enum consists of the following values:
-
None
(default)—Specifies that no checkboxes are displayed in the control. -
Independent
—Specifies that the checkboxes are checked and unchecked independently. The checked state of the parent item is not propagated to its children. -
Recursive
—Specifies that the checkboxes are checked and unchecked recursively. The checked state of the parent item is propagated to its children.
Here is how the Independent CheckBoxMode
looks:
Here is how the Recursive CheckBoxMode
looks:
To display checkboxes in the TreeView item, set the
CheckBoxMode
toIndependent
orRecursive
.
Checked Items Collection
The control exposes a CheckedItems
collection (IList
). The collection holds the items that are currently checked.
Programmatically Check or Uncheck All Items
The TreeView exposes two methods that enable you to programmatically check or uncheck all items:
-
CheckAll()
—Checks all items in the control. -
UnCheckAll()
—Unchecks all items in the control.