This guide focuses on hierarchical navigation and expansion control APIs.
HierarchicalTreeDataGridSource<TModel> provides:
Expand(IndexPath)Collapse(IndexPath)ExpandAll()CollapseAll()ExpandCollapseRecursive(Func<TModel, bool>)ExpandCollapseRecursive(HierarchicalRow<TModel>, Func<TModel, bool>)Example:
Source.Expand(new IndexPath(0));
Source.Expand(new IndexPath(0, 2));
Source.Collapse(new IndexPath(0, 1));
Source.ExpandCollapseRecursive(model => model.Name.StartsWith("A"));
This is useful for search/filter style expansion.
Lifecycle events on source:
RowExpandingRowExpandedRowCollapsingRowCollapsedUse them for telemetry, lazy loading markers, or command state updates.
if (Source.TryGetModelAt(new IndexPath(0, 1, 3), out var model))
{
// model found
}
Use this for actions driven from saved IndexPath values.
var path = new IndexPath(0, 1, 3);
Source.Expand(path[..^1]);
var rowIndex = Source.Rows.ModelIndexToRowIndex(path);
if (rowIndex >= 0)
grid.RowsPresenter?.BringIntoView(rowIndex);
IndexPath helpers:
path[..^1]path.Append(childIndex)IsAncestorOf, IsParentOfWith HierarchicalExpanderColumn<TModel> use isExpandedSelector to bind expansion state to model property.
This is recommended when tree state should survive rebind/reload.
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.