0

I am trying to display items in a grid however the rows and the columns should be generated dynamically. I actually implemented a custom control that derives from Grid control and provide additional properties such as RowCount.

Here is a picture of the grid generated by my custom control using two dimensinal string array as datasource:

enter image description here

But i think my control consumes more than needed resources because it simply destroys column and row definitions and recreates them. Is there any simpler way to implement that control?

Sankarann
  • 2,625
  • 4
  • 22
  • 59
cemtuver
  • 83
  • 1
  • 6

1 Answers1

1

You don't need to create a custom control to do that for you... you can use a standard DataGrid. There have been a number of questions on displaying dynamic data in a DataGrid. Please take a look at some of these posts:

How do I bind a WPF DataGrid to a variable number of columns?
DataGridColumn Binding with Dynamically Generated Data
Visualizing 2D Data in a Table
Displaying multidimensional data in WPF

Community
  • 1
  • 1
Sheridan
  • 68,826
  • 24
  • 143
  • 183
  • Actually i need to because the custom grid should provide much more features such as headers on the left. – cemtuver Jan 16 '14 at 13:02
  • 1
    What? Do you mean like the `DataGrid.RowHeader`??? Take a look at the [DataGrid Properties](http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid_properties(v=vs.110).aspx) *before* you dismiss it. – Sheridan Jan 16 '14 at 13:08