1

I want to create grid in WPF, which is dynamiccally grows depending on the array length that is in the view model. So in view model I have three props:

public string[] HorisontalNames {get;}
public string[] VerticalNames {get;}
public double[,] Values {get;set;}

Is that possible? I want it to be simple for view model.

Archeg
  • 8,111
  • 5
  • 37
  • 85

1 Answers1

1

You would need to remodel your data a bit in your view model, and you can use a solution such as the one provided by Meleak at https://stackoverflow.com/a/4379965/248164.

This attached property will let you bind your DataGrid columns to a collection of DataGridColumn on your view model. These will be your horizontal names.

The vertical names will be the values of the first column.

Community
  • 1
  • 1
devdigital
  • 33,892
  • 9
  • 95
  • 119