I'm trying to add items to a DataGrid, unlike when I have used x.Items.Add(x); for a ListView it only shows blank rows. This DataGrid will only show 1 row at a time and must be editable, if you think there is a better approach rather than a DataGrid then I am open to suggestions. I've made sure the number of values matches the number of columns which was an issue to start with but it seems I am still no closer to solving this. I've tried reading many similar questions but none has solved my issue, where am I going wrong with this?
rw_container is a blank Grid I am using to insert the DataGrid into
private void AddGrid<T>(T obj) where T : ICategory
{
data = new DataGrid();
PropertyInfo[] props = typeof(T).GetProperties();
foreach (PropertyInfo x in props)
{
data.Columns.Add(new DataGridTextColumn() { Header = x.Name, Width = 100 });
}
//How to add the rows here?
rw_container.Children.Add(data);
}