I am using the WPF grid with a DataVirtualizing DataSource, and I am having a sporadic exception being thrown that crashes the application.
The exception is this:
"An item with the same key has already been added."
with a stack trace of:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Xceed.Wpf.DataGrid.VirtualListTableOfContent.AddPage(VirtualPage page)
at Xceed.Wpf.DataGrid.VirtualList.FillEmptyPage(AsyncQueryInfo asyncQueryInfo, Object[] fetchedItems)
at Xceed.Wpf.DataGrid.VirtualPageManager.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)
at Xceed.Wpf.DataGrid.DataGridPageManagerBase.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)
at Xceed.Wpf.DataGrid.DataGridPageManager.OnQueryItemsCompleted(VirtualPage page, AsyncQueryInfo queryInfo, Object[] fetchedItems)
at Xceed.Wpf.DataGrid.VirtualPage.AsyncQueryInfo_EndQueryItems(AsyncQueryInfo queryInfo, Object[] fetchedItems)
This exception is not reproducible reliably. I have a virtualized grid with a page size of 100, maxRealizedItemCount of 1000, and a total count of 5000 records in the data source. I query a WCF service in the QueryItems event handler using the supplied page count and start index. On average, randomly skipping around the result set via the scrollbar will cause the grid to crash after 10-15 page retrievals.
Has anyone else experienced these intermittent issues with a virtualized data source?
Thanks!