I found that the easiest way is to use datatables and create dynamically:
DataTable dt = new DataTable(); int nbColumns = 10; int nbRows = 5; for (int i = 0; i < nbColumns; i++) { dt.Columns.Add(i.ToString(), typeof(double)); } for (int row = 0; row < nbRows; row++) { DataRow dr = dt.NewRow(); for (int col = 0; col < nbColumns; col++) { dr[col] = col; } dt.Rows.Add(dr); } myDataGrid.ItemsSource = dt.DefaultView;
Of course, this is just a random table, you can load your 2d or Xd array into your DataTable. Also, you don't need to implement IEnumerable and stuff ...
source share