This guide covers sorting behavior and column width mechanics.
Sorting is requested through source:
using System.ComponentModel;
Source.SortBy(Source.Columns[0], ListSortDirection.Ascending);
UI headers call this when clicked (if sorting is enabled).
Sorting must be enabled at both levels:
TreeDataGrid.CanUserSortColumnsColumnOptions<TModel>.CanUserSortColumnIf either disables sorting, user header click does not sort that column.
Order of precedence for comparison:
CompareAscending / CompareDescending in column optionsSortBy(...) returns false when sorting cannot be performed for the given column.
After successful sort:
SortDirection on sorted columnSortDirection is visual indicator; changing it directly does not sort source.
Each column has preferred Width (GridLength) and runtime ActualWidth.
Supported width modes:
AutoPixelStarAdjust at runtime:
Source.Columns.SetColumnWidth(0, new GridLength(240, GridUnitType.Pixel));
Source.Columns.SetColumnWidth(1, GridLength.Auto);
From ColumnOptions<TModel>:
MinWidthMaxWidthExample:
new TextColumn<Person, string>(
"Name",
x => x.FirstName,
options: new TextColumnOptions<Person>
{
MinWidth = new GridLength(80),
MaxWidth = new GridLength(260),
})
User drag-resize requires:
CanUserResizeColumns = trueCanUserResizeColumn != false (null inherits grid setting)Double-clicking header resizer resets column to Auto width.
Star columns share remaining viewport width after fixed/auto columns are measured.
If star widths hit min/max constraints, remaining unconstrained stars are recalculated.
Use these checks when sorting behavior or width calculations look wrong.
Expected: row drag/drop move is disabled on sorted sources.
Review MinWidth, MaxWidth, and template measure behavior.