TreeDataGrid supports two primary selection modes:
The active behavior comes from ITreeDataGridSource.Selection.
If you do not assign Selection explicitly:
This makes basic keyboard/mouse selection work immediately.
Main API:
TreeDataGridRowSelectionModel<TModel>ITreeDataGridRowSelectionModel<TModel>Common operations:
SelectedIndex (IndexPath)SelectedIndexes, SelectedItem, SelectedItemsSingleSelect = falseExample:
Source.RowSelection!.SingleSelect = false;
Source.RowSelection.SelectedIndex = new IndexPath(0, 1);
Main API:
TreeDataGridCellSelectionModel<TModel>ITreeDataGridCellSelectionModel<TModel>Common operations:
SelectedIndex (CellIndex)SelectedIndexesSetSelectedRange(...)Example:
Source.Selection = new TreeDataGridCellSelectionModel<Person>(Source)
{
SingleSelect = false,
};
Switch by replacing Source.Selection:
if (useCellSelection)
Source.Selection = new TreeDataGridCellSelectionModel<Person>(Source);
else
Source.Selection = new TreeDataGridRowSelectionModel<Person>(Source);
Requirement: assigned selection model must point to the same Items source.
Core contracts:
ITreeSelectionModelITreeDataGridSelectionITreeDataGridSelectionInteractionAdvanced events from selection base model:
SelectionChangedIndexesChangedSourceResetSourceReset is important when source collections raise reset notifications.
For keyboard/range logic, selection models track:
AnchorIndexRangeAnchorIndexThis supports shift-range operations and consistent keyboard navigation behavior.
IndexPath, CellIndex) rather than visible row numbers.Feature behavior differs from expectations
Cause: one or more options in this scenario are configured differently (source type, column options, sort/selection/edit state).
Fix: compare your setup with the snippet in this article and verify runtime values on Source, Columns, and Selection.
Data changes are not visible in UI
Cause: model or collection notifications are missing, or a replaced collection/source is not re-bound.
Fix: ensure INotifyPropertyChanged/INotifyCollectionChanged flow is active and reassign Source after replacing underlying collections.