I am working with a requirement for displaying a 2 dimensional array in a WPF window. The size of array can be up to 360*720. I have tried to use DataTable bound to a DataDrid, but it took so much time to load the grid and very RAM consuming. My example code is below.
public void SetData(double[][] array)
{   
    if(array.Length <= 0)
        return;
    DataTable table = new DataTable();
    for (int i = 0; i < array[0].Length; i++)
    {
        table.Columns.Add(i.ToString(), typeof(double));
    }
    for (int i = 0; i < array.Length; i++)
    {
        DataRow row = table.NewRow();
        for (int j = 0; j < array[i].Length; j++)
        {
            row[j] = array[i][j].ToString();
        }
        table.Rows.Add(row);
    }
    dataGrid.DataContext = table;
}
I created an array of double of which the dimension is 360 * 720 and called the SetData() method above. As a result, the RAM occupied by the program increased several GBs and very time consuming.
I wonder if there is a graceful way to solve this problem or there are some shortcomings in my code. Thank you.
 
    