I am quite new to avalonia and have been tasked with converting a C# winforms application over to Avalonia, and I've hit a bump.
I'm creating multiple DataGrids dynamically (one datagrid for each student schedule), so this is done in the code as below:
for (int i = 0; i < studentcount; i++) {
DataGrid dg = new DataGrid();
var date = new DataGridTextColumn();
date.Header = "Date";
// date.Binding = new Binding("date"); ?
dg.Columns.Add(date);
canvas.Children.Add(dg);
}
From what i've seen through WPF, it is possible to bind each column to a struct property, with
date.Binding = new Binding("date");
(where date is a string property of a struct), so this way I can add items as
dg.Items.Add(new Student { date = "1/1/2022" });
However from what i've seen, as avalonia bindings work different to WPF, this isn't possible to add a binding in code as above. What alternative is available, or is there a way to work around this?
Cheers