I have a problem with adding a row to a Datagrid in C# WPF.
I have made a Struct for the data:
public struct MyData
{
public int id { set; get; }
public string title { set; get; }
public int jobint { set; get; }
public DateTime lastrun { set; get; }
public DateTime nextrun { set; get; }
}
and a method to add the data:
private void Add_Data_Grid_Row(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
DockPanel panel = button.Parent as DockPanel;
DataGrid usedDataGrid = panel.Children.OfType<DataGrid>().FirstOrDefault();
usedDataGrid.Items.Add(new MyData { id = 11123, title = "King", jobint = 1993123, lastrun = DateTime.Today, nextrun = DateTime.Today });
}
Can you help me out somehow?