Reputation: 193
I am new in programming. I have a question about data biding in WPF.
I have two double arrays and would like to bind them to datagrid with two columns like:
-double[] acce goes to a column in datagridview with a header of "Acceleration"
-double[] peri goes to a column in datagridview with a header of "Period"
I googled this issue but could not find out the right one. An example showing how will be greatly appreciated. Thanks,
Upvotes: 0
Views: 492
Reputation: 7344
You can't do that; you have to bind to one object. You could create a a double[,] array (i.e. a 2D array) and copy acce into one column ([0, x]) and peri into the other ([1, x]) and bind to this new array:
double[,] combined = new double[2, acce.Length];
for (int i = 0; i < acce.Length; i++)
{
combined[0, i] = acce[i];
combined[1, i] = peri[i];
}
..and then bind to combined. Or you get more ambitious (and possibly learn some more) and create a class as @FelixCastor suggested.
PS the code above assumes that peri and acce have the same length.
Upvotes: 1