Scrolling in RadDataBoundListBox too rapidly casues System.ArgumentOutOfRangeException. ItemsSource is bound to a VirtualizingDataCollection with automatic virtualization mode.
I have not been able to find a pattern to the issue. It happens randomly.
It is the exact a same problem as:
http://www.telerik.com/community/forums/windows-phone/databound-listbox/loading-data-on-raddataboundlistbox-in-wp7-manga-beta-7-1.aspx
24 Answers, 1 is accepted
Thanks for writing and for reporting this issue.
Can you please send us a sample that implements your scenario? We will try to reproduce it on our side and provide a fix for the case.
Thanks for your time.
Kind regards,
Deyan
the Telerik team
Basically is the same problem as you had with WinPhone7. It si pretty basic to recreate.
I am running it in the Nokia 920 Windows Phone 8
1. Basically create a List<T>() as my local buffer, 1000 items
2. Create VirtualCollection
3. Set ItemsLoading to read from the List<T>().
4. Quickly try scrolling up and down. Eventually you get the error.
Here is a snippet of my code.
Xaml:
<telerikPrimitives:RadDataBoundListBox x:Name="ctrlDataBoundListBox"
DataVirtualizationMode="Automatic"
Margin="0,10,0,-3"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsCheckModeEnabled="True"
IsAsyncBalanceEnabled="True"
>
Code creating the virtualized collection:
/// <summary>
/// REload all subscribtion in the back ground
/// </summary>
private void LoadSubscriptions()
{
//DefaultLogger.Logger.Trace("Re-Loading subsciptions..." + View.ctrlDataBoundListBox.Verbose());
ViewModel.IsRefreshing = true;
ViewModel.IsCheckModeActive = false;
PodcastApp.RunInBackground(() =>
{
VirtualizingDataCollection subscribedCollection = null;
TryTimer.RunInTimerLog("Retrieving Data", () =>
{
SubscribedPodcastFeed = new List<PodcasterSubscriptionViewModel>(AppDataStore.PodSubscViewModels); // SampleData.PodSubscViewModels(PodAppConfiguration.MaxItems).ToList();
subscribedCollection = new VirtualizingDataCollection(SubscribedPodcastFeed.Count(), PodAppConfiguration.MaxPageSize);
subscribedCollection.LoadItems(0, SubscribedPodcastFeed.Take(PodAppConfiguration.MaxPageSize));
Thread.Sleep(2000); // Testing mock
});
PodcastApp.RunInGuiBackground(() => TryTimer.RunInTimerLog("Binding loaded data", () =>
{
//DefaultLogger.Logger.Trace("Re-Loading subsciptions in GUI..." + View.ctrlDataBoundListBox.Verbose());
ViewModel.SubscribedCollection = subscribedCollection;
ViewModel.SubscribedCollection.ItemsLoading += (sender, args) =>
{
DefaultLogger.Logger.Trace(string.Format("Loading SubscribedCollection Virtual Elements at Start: {0} - Count: {1} - EndIndex: {2} - SubsId: {3}", args.StartIndex, args.Count, args.EndIndex, View.ctrlDataBoundListBox.Verbose()));
ViewModel.SubscribedCollection.LoadItems(args.StartIndex, SubscribedPodcastFeed.Skip(args.StartIndex).Take(args.Count));
};
ViewModel.IsRefreshing = false;
}));
});
}
Thanks for getting back to me and please excuse me for the delay with my answer.
I will take the time to implement your scenario on my side and try to reproduce the exception. Once we determine the reason for it, we will fix the bug and issue an Internal Build (not later than the next week) containing it.
Let me know if the issue is a showstopper for you and you need the fix faster.
All the best,
Deyan
the Telerik team
I'm getting the same error when using VirtualizingDataCollection. I'm trying to scroll down.
I took the latest internal build. Here's the stack trace
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Telerik.Windows.Controls.StackVirtualizationStrategy.GetTopVisibleContainer()
at Telerik.Windows.Controls.RadVirtualizingDataControl.GetTopVisibleItem()
at Telerik.Windows.Controls.RadVirtualizingDataControl.GetIndexOfViewportTopItem()
at Telerik.Windows.Controls.VirtualizationStrategy.UpdateScrollParams()
at Telerik.Windows.Controls.RadVirtualizingDataControl.ManageViewport()
at Telerik.Windows.Controls.RadVirtualizingDataControl.BalanceVisualSpace()
at Telerik.Windows.Controls.RadVirtualizingDataControl.OnVerticalScrollOffsetChanged(Boolean balanceImmediately)
at Telerik.Windows.Controls.RadDataBoundListBox.OnVerticalScrollOffsetChanged(Boolean balanceImmediately)
at Telerik.Windows.Controls.RadVirtualizingDataControl.OnCompositionTarget_Rendering(Object sender, EventArgs e)
at System.Windows.Media.CompositionTarget.OnRendering(Object sender, RenderingEventArgs e)
at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)
Here is the code I'm trying to execute:
private async void HistoryItemsVirtual_ItemsLoading(object sender,
VirtualizingDataCollectionItemsLoadingEventArgs e)
{
var data = await ServiceManager.Instance.GetHistoryItems(CalculatePage(e));
await AsyncMethodCompleted(data);
if (data != null && data.ResponseData != null)
{
HistoryItemsVirtual.LoadItems(CalculateIndex(Convert.ToInt32(data.UserData[ParameterConsts.P_PAGE])),
data.ResponseData);
return;
}
}
Can you please send us a sample project where we can reproduce the exception? This is important for us since it will help us reproduce it on our side and be able to debug our code.
In order to be able to send us a project, you will have to open a new support ticket and attach it there.
Thanks for your time!
Greetings,
Deyan
the Telerik team
-David C
I am writing to inform you that we have been able to reproduce the undesired behavior and are currently working on fixing it.
We will try to include the fix in the upcoming SP1 release of RadControls for Windows Phone.
Do not hesitate to let us know in case of further questions.
Regards,
Deyan
the Telerik team
Hi,
I have Q1 2013 SP1 (version 2013.1.418) and i think problem still exists. I have AsyncBalanceMode = AsyncBalanceMode.Standard.
Regards
Marcin
Thanks for writing.
We are not able to reproduce the issue with the SP1 assemblies. Can you make sure that you correctly reference the latest assemblies before testing?
If you think an issue still exists, please open a new support ticket and send us a sample which reproduces it so that we can take a look and react accordingly.
Thanks for your time.
Regards,
Deyan
the Telerik team
Some of the things I do with the RadDataboundListBox.
1. Insert new items asynchronously
2. Scroll to a given item after the data has loaded
3. Scroll to the top of the list automatically
I really wish I could add more to help, but I can't recreate it myself either.
We have received your support inquiry regarding this issue. We are willing to address it as soon as possible and have asked you for some details in your ticket.
Please take a look at it and let us know if you need further assistance.
Greetings,
Deyan
the Telerik team
Hi Telerik
I'm having similar error. I’m using Pivot and RadDataBoundListBox as DataTemplate for PivotItem in my application. In some cases after changing orientation (from portrait to landscape – my app supports both) RadDataBoundListBox throws ArgumentOutOfRangeException. Unfortunately I wasn’t able to reproduce this issue in separate project, but maybe call stack from my application will help. I cannot send you application because of policy of company. I’m using 2013.1.418.3040 version of your api.
Best regards
Tomasz
Call stack:
mscorlib.ni.dll!System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument argument, System.ExceptionResource resource)
mscorlib.ni.dll!System.Collections.Generic.List<Telerik.Windows.Controls.RadVirtualizingDataControlItem>.this[int].get(int index)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.StackVirtualizationStrategy.GetTopVisibleContainer()
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadVirtualizingDataControl.GetTopVisibleItem()
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadVirtualizingDataControl.GetIndexOfViewportTopItem()
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.VirtualizationStrategy.UpdateScrollParams()
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.StackVirtualizationStrategy.OnContainerSizeChanged(Telerik.Windows.Controls.RadVirtualizingDataControlItem container, System.Windows.Size newSize, System.Windows.Size oldSize)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadVirtualizingDataControl.OnContainerSizeChanged(Telerik.Windows.Controls.RadVirtualizingDataControlItem container, System.Windows.Size newSize, System.Windows.Size oldSize)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadVirtualizingDataControlItem.InvalidateCachedSize(System.Windows.Size newSize)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadDataBoundListBoxItem.InvalidateCachedSize(System.Windows.Size newSize)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadVirtualizingDataControlItem.InvalidateCachedSize()
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.StackVirtualizationStrategy.MeasureContainer(Telerik.Windows.Controls.RadVirtualizingDataControlItem container)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.StackVirtualizationStrategy.OnViewportSizeChanged(System.Windows.Size newSize, System.Windows.Size oldSize)
telerik.windows.controls.primitives.DLL!Telerik.Windows.Controls.RadVirtualizingDataControl.OnSizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
System.Windows.ni.dll!System.Windows.FrameworkElement.OnSizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
System.Windows.ni.dll!MS.Internal.JoltHelper.RaiseEvent(System.IntPtr target, uint eventId, System.IntPtr coreEventArgs, uint eventArgsTypeIndex)
Ok. I’ve replaced all dll’s in my project with equivalent projects from available source code, compiled it and debugged it. It seems (at least for me) that the problem lies in GetTopVisibleContainer() method. In some cases countOfTopVisibleItems can be negative. In my case it was -139. Line after this field is initialized it’s used to obtain element from array (array[countOfTopVisibleItems]) and because it’s negative ArgumentOutOfRangeException is thrown.
Other important fields has following values (in my case):
topThresholdAbs: 830
averageItemHeight: -5.9444444444444446
realizedItems.Count: 18
topVirtualizationThreshold: -830
I hope this will help you. Please let me know if you managed to fix this issue.
Best regards.
Thanks for writing back and for the extensive feedback.
Indeed, this sounds like an issue but it will be extremely helpful to know some further details about the scenario in which it occurs? I can see that the averageItemHeight field has a negative value as well which is not supposed to happen.
In the normal workflow of the control this logic works as expected and we cannot reproduce this exception. We also do not want to simply make a check and prevent the logic execution in case the values are not expected. Can you please share with us how exactly the issue happens so that we can try to reproduce and see how we can fix it?
Thanks for your time!
Regards,
Deyan
Telerik
Hi Deyan
I use pivot as collection of tabs and RadDataBoundListBoxes as collection of fields on each tab. RadDatabounListBox has AsyncBallance enabled. It also have DataTemplateSelector. DataTemplates for fields are different. They have different sizes and content. Size of fields can also change while user is filling form. In my case I’m just filling few fields scrolling list down, and changing orientation. And that’s all.
I've debugged your code further and I've discovered that “averageItemHeight” is negative, because “realizedItemsLength” (in method RecalculateViewportMeasurements) is negative too.
I’m not sure if I’m right but I think it is because of using different sized templates.
In method “OnViewportSizeChanged” “realizedItemsLength” value becomes 0. Then there is a loop. I’ve spotted that in normal circumstances “IsItemSizeChangeValid” returns “false” for first few items. In consequence “realizedItemsLength” becomes greater than zero. In case where exception is thrown “IsItemSizeChangeValid” returns “true” for first item. I guess it’s because templates have different sizes and different template is taken. But it’s only a guess. Anyway “realizedItemsLength” is now 0. Because of this if “diff” field in “OnContainerSizeChanged” method is negative “realizedItemsLength” will also be negative.
Please let me know if you need any other information. I hope this will help.
Best regards
Thanks for the really useful information.
For now the only thing I will need is a sample project that reproduces the exception so that we can also debug the code and see how to fix the issue.
Is it possible for you to open a new support ticket and attach such project?
Regards,
Deyan
Telerik
Hi Deyan
I'm sorry that I write to you from different accounts. From now on I’ll try to write to you from this account only.
As for opening ticket it’s currently not possible. I wasn’t able to reproduce this issue in separate project. Moreover my company is still in process of renewing subscription. I assume that it will take few days or weeks. However having this issue fixed in newest version will be good reason to speed up this process.
Best regards
Tomasz
Thanks for writing back.
Can you please share with us which version of RadControls you are using? Since we have addressed similar issues before, we want to make sure it is something we need to additionally take a look at and is not something we have already addressed in our latest build.
Regards,
Deyan
Telerik
Thanks for your response.
We use version: 2013.1.418.3040 in our application. However to debug this issue, I have used source code in version 2013.1.911.3040
Best regards
Tomasz
We are going to look into the code. I also want to make a note that we have addressed a similar issue in April this year which means that your issue might be resolved in the builds past Q2 2013.
Let me know should you have further questions or need assistance.
Regards,
Deyan
Telerik
Everything works in the latest version. At least for me.
Thank you.
Best regards
Tomasz
Good to hear.
Please let us know if something emerges as we are actively tracking these issues and want to make sure they do not appear.
Regards,
Deyan
Telerik