TreeView Selection
The TreeView lets the user select one or more nodes. You can also pre-select them with your own code.
You can configure the node selection behavior by setting the SelectionMode parameter to a member of the TreeViewSelectionMode enum:
You get or set the selected items through the SelectedItems parameter. It is an IEnumerable<object> collection. The selection allows two-way binding (@bind-SelectedItems) and one-way binding + SelectedItemsChanged event.
If you want to extract details for the selection from SelectedItems, you need to cast the collection to the correct model type. This is required because you can bind the treeview to different model types at each level. The example below demonstrates this approach - we cast the selected item to the specific model in order to get its details and display them outside of the TreeView.
Enable node selection