DataGridColumns
Overview
Every DataGrid can hold multiple DataGridColumns
. Avalonia has several build-in DataGridColumns
, which can be used to display a certain data type with a certain appearance.
Build-in DataGridColumns
Common Properties for all DataGridColumns
Header
Gets or sets the header content of the column
HeaderTemplate
IsReadOnly
Gets or sets if the column is read-only. If the owning grid is read-only, then the column is also read-only, even if this property is set to true.
DataGridTextColumn
This column is used to display text data, normally represented by a string
. In the normal state the text is displayed in a TextBlock
. If the user edits the current cell, a TextBox
will be shown. This column has some properties which can be used to control the appearance like FontSize
and FontFamily
.
Example
API Reference
Source code
DataGridCheckBoxColumn
This column is used to represent a bool
value. The value is represented by a CheckBox
, which is disabled in the normal state and enabled in the editing state of the DataGridCell
. If needed you can enable the indeterminate state by setting the property IsThreeState
to true.
Example
API Reference
Source code
DataGridTemplateColumn
This column is used to display any content you like. There are two https://github.com/avaloniachina/Documentation/blob/master/misc/wpf/datatemplates.md which you can define, the CellTemplate
for the normal state and the CellEditingTemplate
for the editing state of the current DataGridCell
.
The DataGridTemplateColumn is editable from Avalonia version 0.10.12 onward. If you do not set a CellEditingTemplate
, the column will stay read-only.
Example
API Reference
Source code
最后更新于