I have a data table of 60,000 records. There is a loop which validate each record and after validation add rows to another ObservableCollection object. Once all the records are processed ObservableCollection is assigned to xamGrid.ItemsSource.
This takes around 7 seconds for the grid to be visible to user.
Is it possible that I can add records to xamGrid one by one after each record validation instead of first validation all 60,000 records and then render.
I tried the approach mentioned in following link to add new record directly to xamGrid.ItemsSource
xamGrid.ItemsSource
help.infragistics.com/.../xamGrid_Add_New_Row.html
I can see the records are added one by one, but new records are not rendered immediately. Records are visible only once all 60,000 records are added.
Pls advice how can I add new records one by one and same time keep on rendering the grid so that user can have better UI experience.
Hello,
Thank you for posting in our forums!
I suspect you may still be doing the looping on the UI thread, which is why the grid is not updating until the entire data table is validated.
If you can use .NET 4.5+ you could take advantage of the EnableCollectionSynchronization feature here. Note that to use this, you will need to bind the XamDataGrid to the ICollectionView of your ObservableCollection. Please see my attached sample below which demonstrates how you can accomplish this.
7711.XDG_AsyncValidation.zip
If this is not an option for you, the ObservableCollection must be updated on the UI thread and it would be recommended to wait until the validation is completed before displaying the grid.
Please let me know if you have any further questions or concerns with this.
Thanks Michael. Is EnableCollectionSynchronization feature available in xamGrid also?
Hi Ritesh,
The EnableCollectionSynchronization is a WPF (.NET 4.5+) feature. So yes, the same solution will work for the XamGrid. See my updated sample below where the only change is that I swapped out the XamDataGrid for the XamGrid.
7357.XamGrid_AsyncValidation.zip
If you need anything else, please let me know.