Thanks. Can you expand on your answer? I don't know what you mean by data grid "cell types".
I assume you are saying that I should not create an instance of a UI control for each data item. Instead I should have a minimal set of UI controls, and change the data each displays. Clearly for a uniform grid where all controls are the same, or all cells in a given column are the same, that is easy, and it can be done in the view model. However, I might have one row of check boxes, followed by several rows of combo boxes, followed by several rows of hex number edit boxes etc and this can be scrolled vertically.
Some requirements were given in my previous question along with example code, that you replied to, however it was a long post.
We need to display tabular data, in a table with rows and columns. A given data value can be a Boolean, or a combo box selection, or a numeric value (signed or unsigned). In general each value is editable. The table of settings is to be displayed in a WPF view and hence the size will depend on the view size. Clearly not all of the items will be visible to the user as the table is so large, so there will be vertical and horizontal scroll bars.
I had hoped that the DataGrid implemented virtualisation well enough to reduce the overhead, but it appears that WPF is very very memory intensive. When I turn on virtualisation for both columns and rows, the performance is unacceptable (slow).
I haven't tried the list view. I guess I could define a list view item as a GRID control with one row, and multiple columns and use the
property to create columns, assuming that would work, but I can't see why it would reduce the massive memory overhead.
A possible solution I am working on is to use a DataGrid with each item being a Label control. That massively reduces the memory usage. Double clicking on an item makes it editable, displaying the appropriate edit control e.g. CheckBox.
Why not change your UI design to a more sensible layout. List all the setting values in a grid but make the user edit them in a dialog box. The user should have to double click on the grid row he wants to edit, pop a dialog with the data from that row, allow the user to edit the data of the single data row in discreet controls, save the data back to the underlying collection.
The design eliminates the need to editable controls in the data grid and will simplify your life enormously.
Never underestimate the power of human stupidity
Thanks. I might well use that approach, depending on how much progress I make.
Currently I am implementing a solution whereby the grid is read only but when the user double clicks on a cell, it becomes editable. So instead of plain text, they now see a combo box, or a tick box, or a numeric value editor. Double click elsewhere, and the cell becomes read only. This works well with the Microsoft WPF DataGrid though the memory usage is still rather high. The non editable cell control is a Label.
I am also looking at the WPF Table View control on CodePlex. As yet I cannot find out how to make the current cell active when double clicked on, but the memory usage and speed are better. Clearly I can easily pop up a dialog to edit a cell, or a row as you suggest since I can trap the mouse double click.
From searching around it does seem that the performance of grids is a widespread problem.
I agree. However, this is an application for engineers rather than general consumers, and this particular view displays configuration settings that will only be examined by two or three people who are based in our company (super users). The values are rather abstruse, and control fine details of a display device. Most of the time users will just examine the values, and maybe tweak one or two. For general editing we stream the data to and from a .CSV file. So in practice this horrible view will be okay.
Probably not for reasons of commercial secrecy. What I am working on has NDA agreements in place.
However, the current implementation now works well. We generate and compile the form code on the fly, and the form runs pretty quickly to provide a decent user experience. I am using the extended WPF toolkit DataGrid in place of the standard DataGrid which has solved the performance issues.
From searching on the internet, it's clear that the performance of data grids is an issue for a lot of people, and I am sure many have their own custom implementations.
I might be able to significantly reduce the memory footprint, and increase execution time but it would require significant development time which we do not have. We need to focus on the features that our customers will use, rather than gold plate something used from time to time by a couple of our own engineers.
You come across as a troll. Every single one of your posts is a put down. The suggestions you make are vague abstract comments (the kind that someone with no real knowledge could make), with no helpful content and nothing to indicate any actual technical knowledge on your part. Do you have anything constructive to say or is your goal simply to piss on me? Frankly I am getting pissed off with your obnoxious trolling.
The layout was designed by the engineers. It's what they have asked for and what they want. They've seen the current prototype and like it. It's the same as in the previous application which has served them well.
We need to configure a hard ware device, which provides configuration settings as tabular data. There are lots of different sets of tabular data. We want to display a given table in a view, so that the user can edit the fields. All fields in a given row have the same kind of data e.g. integer. However, one row might display integers, another might display a combo box, and another a check box. The problem is how to automatically create the WPF view and view model code.
The nature of the data in each table is defined in an XML file. Unfortunately for one table the number of columns is defined by a value in another table which is only known at run-time.
Thus we can create some tables at build time, but one must be created at run-time.
I created a parser which generates the WPF view and view model for each table of data. This parser can be run at run-time to generate view and view model source code, which is then compiled at run-time, and displayed. So far so good. This works well with one exception, as the number of fields is almost always modest.
Unfortunately one table has ~120,000 cells, and the resulting view model will not run as the number of controls exceeds the maximum allowed by WPF. The view will display and looks good. Clearly having so many properties in a view model is a tad ridiculous and crude.
So, we need a more elegant solution, and one which allows the values to be displayed in a table with cells all nicely aligned.
The view model contains a list of field objects, each of which provides data in the correct format for the corresponding table cell e.g. "true" and "false" for tick box. Is it possible to create a DataGrid, such that it gets its data from my table of fields, and displays the correct kind of control dependent on the nature of the data (which my field object knows)? Thus row 0 might be tick boxes, row 1 edit boxes, and row 2 combo boxes?
I came across some example code that almost solved our problem, and with some changes it does the job in my demo application which I will explain below in case anyone finds this useful. The link is as follows: