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.
Dominik,
Do you have any questions in light of the reply from Engineering above?
Sorry for the delay.
Thanks for your research, just by any chance do you have a small example of a virtualizing datasource that support recycling. Because, I didn't figure out when an item (PersonViewModel instance) is used by XamDataGrid. So that the datasource know when he have to build an item and when he can recycle an item (for a specified index).
Thanks, I really appreciate the effort that you and Infragistic team do to awnser our business needs.
On a side note, if possible, it would be appreciated if the solution for that problem could support the MVVM pattern.
Thanks, continue the good job,
I have logged Feature Request FR13634 for a sample or component that implements a virtualied datasource supporting recycling. I have sent you details in a private support case.
Francis,
Thanks, for your help.
Looking forward for updates.
I checked with the WPF team lead, and we do not have any such sample. I have also sumitted a suggestion to our Product Guidance team for a sample of this kind, but I cannot guarantee if or when we will have one.