TextColumn<TModel, TValue> displays typed values as text and optionally supports editing and text search.
Read-only:
new TextColumn<Person, string>("First Name", x => x.FirstName)
Editable:
new TextColumn<Person, string>(
"First Name",
x => x.FirstName,
(m, v) => m.FirstName = v)
With width and options:
new TextColumn<Person, int>(
"Age",
x => x.Age,
width: new GridLength(120),
options: new TextColumnOptions<Person>
{
StringFormat = "{0} years",
TextAlignment = Avalonia.Media.TextAlignment.Right,
})
TextColumnOptions<TModel> extends ColumnOptions<TModel>.
Text-specific options:
IsTextSearchEnabledStringFormatCultureTextTrimmingTextWrappingTextAlignmentInherited options include:
CanUserSortColumnCanUserResizeColumnCompareAscending / CompareDescendingMinWidth, MaxWidthBeginEditGesturesA TextColumn is editable only when constructor includes setter.
Edit lifecycle in cells:
F2, DoubleTap)When IsTextSearchEnabled = true, row selection keyboard text search can match values from this column.
Example:
new TextColumn<Person, string>(
"Country",
x => x.Name,
options: new TextColumnOptions<Person>
{
IsTextSearchEnabled = true,
})
StringFormat is applied via string.Format(Culture, StringFormat, value).
For nullable values, ensure format handles null cases gracefully.
Numeric with right alignment:
new TextColumn<Order, decimal>(
"Total",
x => x.Total,
options: new TextColumnOptions<Order>
{
StringFormat = "{0:N2}",
TextAlignment = Avalonia.Media.TextAlignment.Right,
})
Long text wrapping:
new TextColumn<Article, string?>(
"Extract",
x => x.Extract,
width: GridLength.Star,
options: new TextColumnOptions<Article>
{
TextWrapping = Avalonia.Media.TextWrapping.Wrap,
TextTrimming = Avalonia.Media.TextTrimming.None,
})
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.