DataGridColumns
Overview
Every . 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
Property | Description |
---|---|
Header | Gets or sets the header content of the column |
HeaderTemplate | Gets or sets a data template for the column (see: datatemplates.md) |
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
<DataGrid Name="MyDataGrid" Items="{Binding People}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Forename" Binding="{Binding FirstName}"/>
<DataGridTextColumn Header="Surname" Binding="{Binding LastName}" />
</DataGrid.Columns>
</DataGrid>