While using RadGridView with VirtualQueryableCollectionView and moving CurrentPosition with any of MoveCurrent* methods, I have found, that CurrentItem is not loaded when CurrentPosition changes to an index of not yet loaded item (in my case LoadSize is 50 and items are loaded from our WCF service) and thus CurrentItem is null.
The problem is in QueryableCollectionView.InternalGetItemAt where
return
this
.InternalList[index];
ignores items loading.
My fix for now is:
public
class
VirtualQueryableCollectionView<T> :
Telerik.Windows.Data.VirtualQueryableCollectionView<T>
{
protected
override
void
OnCurrentChanged(EventArgs args)
{
// fix not loaded CurrentItem is not loaded when CurrentPosition changes
if
(
!IsCurrentBeforeFirst &&
!IsCurrentAfterLast &&
CurrentItem ==
null
)
{
SetCurrent(GetItemAt(CurrentPosition), CurrentPosition);
}
base
.OnCurrentChanged(args);
}
}
It has a drawback that OnCurrentChanged is called twice when this fix is effective.