Row selection is the default selection mode for both flat and hierarchical sources.
By default:
SingleSelect = trueEnable multi-select:
Source.RowSelection!.SingleSelect = false;
Source.RowSelection!.SelectedIndex = new IndexPath(0, 1);
For flat sources, implicit int conversion is available:
Source.RowSelection!.SelectedIndex = 3;
var selection = Source.RowSelection!;
var first = selection.SelectedItem;
var all = selection.SelectedItems;
var indexes = selection.SelectedIndexes;
Available operations (through ITreeSelectionModel):
Select(IndexPath)Deselect(IndexPath)Clear()IsSelected(IndexPath)Batch updates for advanced scenarios:
selection.BeginBatchUpdate();
try
{
selection.Select(new IndexPath(0));
selection.Select(new IndexPath(1));
}
finally
{
selection.EndBatchUpdate();
}
Typed event:
Source.RowSelection!.SelectionChanged += (_, e) =>
{
// e.SelectedIndexes, e.DeselectedIndexes
// e.SelectedItems, e.DeselectedItems
};
Base model events (advanced):
IndexesChangedSourceResetSourceReset is important when the underlying collection raises Reset.
From TreeDataGrid control:
RowSelection property returns active row selection model when in row modeSource differs from source ItemsIndexPathSingleSelect for Ctrl/Shift style multi-selection workflowsFeature 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.