DataGrid
The DataGrid
control is a control that displays data in a customizable grid.
Reference
Source code
Reference required nuget package
To start using DataGrid, you need to reference it in your project first. You can run "dotnet add package" from the command line:
Or add package reference directly to the csproj file:
Note, that version should match Avalonia version you are using.
Add required styles to App.axaml
The Themes can be changed to light or dark to fit your application theme.
Or if you are using new Fluent theme, you will need to include styles created specifically for that:
Examples
Basic DataGrid
This will generate a DataGrid with column header names. FirstName and LastName.
Custom headers
The DataGrid uses the same class Person as before, but now with custom column header name. Forename and Surname.
Common Properties
AutoGenerateColumns
Control if the columns should be automatically generate for display in UI from the bounded data source.
Items
Gets or sets a collection that is used to generate the content of the control.
CanUserReorderColumns
Indicates whether the user can change the column display order by dragging column headers with the mouse.
CanUserResizeColumns
Indicates whether the user can adjust column widths using the mouse.
CanUserSortColumns
Indicates whether the user can sort columns by clicking the column header.
最后更新于