Hello,
I'm trying to create a simple real-time application with the grid control.
Currently our data source is an observable collection of objects that implement INotifyPropertyChanged. It consists of a grid of 1000 rows and 20 columns, where every single value in the data source is updated every 500ms. This means that there are 40,000 updates every second to the data source.
xamDataGrid will lazy subscribe to each row as it appears on screen, however it never unsubscribes, meaning that once you have viewed every row, the grid makes 40,000 calls a second to the dataset to get the data rather than the 400 or so of the cells actually on screen.
Is it possible to somehow setup the grid so that it only actively subscribes to the data that is onscreen at that time? Any suggestions appreciated.
ThanksSteve Mortimer
Hi Steve,
Even though we subscribe to records not in view, I don't understand how it is accessing the data for cells not in view, unless you have set the RecordContainerGenerationMode property to 'PreLoad' or 'LazyLoad' since internally we call CellValuePresenter.FromRecordAndCell and only re-get the cell's value if it returns a non-null value. For RecordContainerGenerationMode 'Recycle' (which is the default) or 'Virtualize' that should only apply to records in view plus possibly a small # of buffered records in the 'Virtualize' case.
Hi Joe, thanks for your respose.
Digging a little deeper and moving the code out into a tester application i think we have moved a little closer to my issue.
You are correct that if we allow the grid to autogenerate the columns the the behaviour is as described. The problem is that we have to generate the columns dynamically as the dataset is really an observable collection of sets of objects. We use reflection at runtime to create UnboundFields and bind into the observable collection of objects.
foreach (PropertyInfo pi in t.GetProperties()){
string bindingPath = string.Format("ColumnSets[{0}].{1}", t.Name, name);
column.Name = name;
column.Label = name;
column.BindingMode = BindingMode.OneWay;
column.DataType = pi.PropertyType;
etc.
So im guessing that this issue is either me not understanding WPF binding, not understanding the correct way of using the grid, or something special about UnboundFields.
Our grid is part of a view which takes a model of data which is extensable via plugins, therefore we dont actually know what columns were going to have until runtime. We did try using a dataset at one point however found its speed slower than an observable collection.
Any ideas on a better way of achieving what we want?
Thanks
Steve