DataGridControl is an interactive, virtualized, data-bound table control intended for large datasets and rich interaction:
scrolling, selection, sorting, searching/filtering, column resizing, and inline editing.
The lower-level contracts and data model live in DataGrid Specs.

Typical usage is:
IDataGridDocument (e.g. DataGridListDocument<T> or DataGridDataTableDocument),DataGridDocumentView) when you want sorting/filtering/search,DataGridControl.View,ScrollViewer to show scrollbars.You can bind DataGridControl.Document directly for the simplest scenario, but using a view is the recommended path
when you want projection (sort/filter) and when the source can change shape.
using XenoAtom.Terminal.UI;
using XenoAtom.Terminal.UI.Controls;
using XenoAtom.Terminal.UI.DataGrid;
public sealed partial class MyRow
{
[Bindable] public partial int Id { get; set; }
[Bindable] public partial string Name { get; set; } = string.Empty;
}
var doc = new DataGridListDocument<MyRow>()
.AddColumn(MyRow.Accessor.Id)
.AddColumn(MyRow.Accessor.Name);
using var view = new DataGridDocumentView(doc);
var grid = new DataGridControl { View = view, FrozenColumns = 1 };
// Optional: provide typed UI columns to enable typed templates/editors and per-column overrides.
grid.Columns.Add(new DataGridColumn<int>
{
Key = MyRow.Accessor.Id.Name,
TypedValueAccessor = MyRow.Accessor.Id,
Width = GridLength.Auto,
CellAlignment = TextAlignment.Right,
Sortable = true,
});
grid.Columns.Add(new DataGridColumn<string>
{
Key = MyRow.Accessor.Name.Name,
TypedValueAccessor = MyRow.Accessor.Name,
Width = GridLength.Star(1),
Sortable = true,
});
var root = new ScrollViewer(grid);
DataGridControl renders columns from the current snapshot:
IDataGridDocumentSnapshot) that describes columns + rows.IDataGridView) projects a document (filtering/sorting), and exposes CurrentSnapshot.grid.Columns.Count == 0), orgrid.Columns) if you want per-column customization.Schema-only mode supports selection, scrolling, search, filtering, and column resizing.
Add grid.Columns when you need typed templates/editors, custom header visuals, or per-column constraints.
Sizing rules are intentionally simple:
Auto: uses header width and a content sample (virtualized).Fixed: uses the given width.Star: participates in filling remaining space.You can resize columns at runtime:
Auto-size scans the entire column. For very large datasets, prefer AutoSizeSampleRowCount-style sizing
(the default auto sizing) and use auto-size on demand.
Sorting is opt-in per UI column:
DataGridColumn.Sortable = true to show the header sort button,DataGridColumn<T>.SortComparer to override the default Comparer<T>.Default,None -> Descending -> Ascending -> None,Ctrl+click adds/removes secondary sorts so multi-column sorts are additive and stable (Alt+click is also accepted).You can also sort programmatically:
grid.TrySetColumnSortDirection(MyRow.Accessor.Name.Name, DataGridSortDirection.Ascending);
grid.TrySetColumnSortDirection(MyRow.Accessor.Id.Name, DataGridSortDirection.Descending, additive: true);
When the view is a DataGridDocumentView, any configured SortComparer is forwarded automatically.
Ctrl+F: open find UI (uses SearchReplacePopup in find mode)F3 / Shift+F3: next / previous matchF4: toggle filter row (when View is filterable)Ctrl+click for additive multi-sort; Alt+click also works)F2 or Enter: edit current cell (when editable)Space, Enter, or a single click without staying in edit modeDataGridColumn.CellActivationMode = DataGridCellActivationMode.DirectActivate can replay button-like actions from the first key press or clickDataGridControl supports:
Ctrl+A to select the entire table,Ctrl+C to copy the current selection.The copied format is plain text designed to paste into editors/spreadsheets (tab-separated values).
Editing is enabled when:
ReadOnly == false, andWhen editing starts, the control chooses an editor:
TextBox for strings (supports selection, scrolling inside the cell, copy/paste, undo/redo),NumberBox for numeric types,Cell activation defaults to a hybrid model:
F2, Enter, second click, or double-click),CellActivationMode = DataGridCellActivationMode.DirectActivate.When the grid is focused but no cell editor is active, Esc now falls through normally, so wrapping dialogs can bind their
own Escape shortcut without the grid reserving it.
If you need a custom cell editor or display, provide a typed DataGridColumn<T> and use templates.
See Data Templating.
DataGridControl exposes a ScrollModel (via IScrollable) so ScrollViewer can render scrollbars and synchronize offsets.DataGridColumn.Key should match DataGridColumnInfo.Key from the snapshot.HorizontalAlignment = Align.Stretch, VerticalAlignment = Align.Stretch