0

I want to add some data with variable count of rows and columns to the WPF form, edit it and get it back (for future save & load).

All I want to know is a what approach is best for that?

I have tried the DataGrid but it seems to be allowing me to edit cells only if I set the ItemSource property but I can't do that because I am adding columns at the run time without any class instances because each time the column count differs.

For example:

I need a 5x60 (5 columns and 60 rows) table. Then (in a say 5 minutes) I need a 9x30 (9 cols, 30 rows) table. Then another one. And all the time I need to have the DataGrid (or whatever) to be editable.

2
  • There is no clean way that I know of. You can bind columns in code behind to dataCol[0], dataCol[1] ... but it is still going to expect the same number of columns in each row. You might be able to create for the max and then bind to an active to disable. Only a comment. I use this for column count at run time but each row has the same number of columns.
    – paparazzo
    Jun 12, 2012 at 19:27
  • You should post examples of your data and how it needs to be displayed. You can probably configure a DataGrid in code at runtime. When a DataGrid is configured at design time in XAML, it usually assumes a particular data format. If the expected format is actually random then you need to programmatically design your grid. Jun 12, 2012 at 19:34

1 Answer 1

0

It seems to be the only way is to create the TextBox-filled UniformGrid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.