I am using the Data Virtualization as described by Paul McClean : http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx
It works fine with a ListView control.
but when I use it with a DataGrid control (AsyncVirtualizationCollection), it throws exceptions :
"Value cannot be null, parameter name : key"
I don't what is the cause and how to stop that from happening. I need the editing features of DataGrid control
I ran into this too. It turned out the issue was this code in VirtualizingCollection (base class of AsyncVirtualizingCollection):
public T this[int index]
{
// snip
// defensive check in case of async load
if (_pages[pageIndex] == null)
return default(T);
// snip
}
If T is a reference type, default(T) is null, and DataGrid doesn't appreciate null row objects.
To solve this, I added a public property to VirtualizingCollection to hold the default value:
public T DefaultValue = default(T);
and changed the above code to return DefaultValue instead of default(T). Then, when I construct my AsyncVirtualizingCollection, I set DefaultValue to a dummy object that is displayed while loading is in progress.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With