Hi,
I have a 3-tier application (WCF, WPF, Prism, Unity and MVVM), I receive 1M models (for example Person) from the server which need to be shown in the XamDataGrid. My ViewModel exposes an ObservableCollection<PersonViewModel>, where PersonViewModel are simply wrapper around the model Person. Those wrapper are kind of big, and long to construct since the constructor parameters are mapped dynamically by unity framework. Would it be possible to lazy build those wrappers and ideally recycle them (basically virtualize them), so that only the shown records have a wrapper instance? It's require that the solution work with filtering, sorting and grouping!
Thanks,Dominik
Hello Dominik,
The XamDataGrid requires all of the records to be loaded to provide filtering, sorting and grouping.
If you have further questions, please let me know.
Thanks,
Hi Francis,
Thanks for your answer.
Still, do you have any suggestion to handle that kind of problem.
Regards,
Dominik
Hi Dominik,
I'm checking into this and will post here what I find out.
I received information from our WPF Engineering team; apparently, there is a considerable amount of work to do to accomplish this. Hopefully, this explanation helps:
In the case without sorting or grouping, the control only asks for the data as the data is brought into view. So the PersonViewModel wrappers would effectively be created lazily.
However, once a record is brought into view, and we ask the data source for the corresponding dataitem (which in this case is the PersonViewModel wrapper), we don’t ‘discard’ the dataitem when the record goes out of view. So, there is no way to recycle the wrappers. Plus, if [you] are using sorting and filtering then the ‘lazy load’ won’t even happen, because we ask for all the records up front.
There are no XamDataGrid options to achieve this requirement. [You] would have to implement a virtualizing datasource that supports recycling. That’s not a trivial task.
Hello Francis,
I would like to second this feature request, but couldn't figure out how to do so.
Meanwhile:
Francis"] we don’t ‘discard’ the dataitem when the record goes out of view.
we don’t ‘discard’ the dataitem when the record goes out of view.
Is there a way to discard the dataitem (i.e. the reference the record is holding) by hand?
Hello [rmrop],
I have created a private support case to follow up with you and giving details about Feature Request FR13715 logged on your behalf.
Regarding your question about removing the dataitem; here is the reply I have from our Engineering team:
Once a Record has been created and the dataitem referenced, there is no way to discard the Record and its reference to the dataitem without sending a Reset notification from the datasource to which the grid is bound. (Note: in order for the Record to be discarded in this case the DataGrid’s DataSourceResetBehavior property must be set to DiscardExistingRecords).
Thanks
thanks for your reply. That's just the Information I needed.
I already tried sending Reset notifications, but did not know about the "DataSourceResetBehavior = DiscardExistingRecords" -requirement. After adding this Setting, my virtual DataSource is able to discard obsolete data.
At least almost all of it:
For some reason when in DiscardingExistingRecords-Mode the xamDataGrid requests the first DataItem on each Reset-Notification. This blocks the first chunk of data from ever getting deleted from the virtual DatatSource, because it seems to be needed all the time.
But as that only affects the lifespan of the first chunk of data, I think we can go by this solution at the moment. Until XamDataGrid has build-in support for virtual DataSources.
@Dominik:
Your idea is quite nice as well: Using Wrappers to reduce the size of the DataItems to nearly nothing. But: a million times nearly nothing still results in somthing big.
So that would probably not work for us.
Anyway, thanks for your suggestion
regards,