This is a migrated thread and some comments may be shown as answers.

Bug when setting items per page?

5 Answers 101 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 29 Sep 2008, 04:02 PM
I am using the RadCarouselPanel inside a ListBox and have always set ItemsPerPage to be around 20.  When I decided to lower this to 5 or 10, I get "index was outside the bounds of the array" when clicking on the item in my ListBox.  If I set back to 20, it works again.

This is the stacktrace for the exception:


         StackTrace    "   at Telerik.Windows.Controls.Carousel.Animations.DecreaseItemsPerPageAnimation.AddItemToStay(ChildIndexPair item)\r\n   at Telerik.Windows.Controls.Carousel.Animations.DecreaseItemsPerPageAnimation.AddItemToAnimate(ChildIndexPair item)\r\n   at Telerik.Windows.Controls.RadCarouselPanel.PrepareAnimation(PathAnimation animation)\r\n   at Telerik.Windows.Controls.RadCarouselPanel.RunScheduledAnimation()\r\n   at Telerik.Windows.Controls.RadCarouselPanel.MeasureOverride(Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Page.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Control.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)\r\n   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)\r\n   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Decorator.MeasureOverride(Size constraint)\r\n   at System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Controls.Border.MeasureOverride(Size constraint)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.Window.MeasureOverrideHelper(Size constraint)\r\n   at System.Windows.Window.MeasureOverride(Size availableSize)\r\n   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)\r\n   at System.Windows.UIElement.Measure(Size availableSize)\r\n   at System.Windows.ContextLayoutManager.UpdateLayout()\r\n   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)\r\n   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()\r\n   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()\r\n   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)\r\n   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)\r\n   at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)\r\n   at System.Windows.Interop.HwndTarget.OnResize()\r\n   at System.Windows.Interop.HwndTarget.HandleMessage(Int32 msg, IntPtr wparam, IntPtr lparam)\r\n   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)\r\n   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)\r\n   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)\r\n   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)"    string

5 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 01 Oct 2008, 06:57 AM
Hi Scott,

I was unable to reproduce the exception that you reported. May I ask you to open a support ticket and send us a sample project where this problem is evident? This would really help us solve the problem in a more timely fashion.

We have updated your Telerik points as per our EAP Program.

Greetings,
Milan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Scott
Top achievements
Rank 1
answered on 01 Oct 2008, 06:26 PM
What was happening is that I had initialized my panel with ItemsPerPage=19.  Then based on some other criteria, I changed ItemsPerPage to 5.  This is what caused the problem index out of range problem in the carousel.  After removing the initialization code, it works fine now.  I thought that by initially setting it to 19, and then overriding when needed, it wouldn't cause a problem, but in this case it did.

0
Milan
Telerik team
answered on 02 Oct 2008, 03:24 PM
Hello Scott,

It is great to hear that you have found a workaround. Yet, could you please be more specific about the place (constructor, event handler, etc) where you first initialized the ItemsPerPage property to 19, and then changed it to 5?
That kind of information will be very helpful since we will be able to trace your steps and fix the problem.

Thanks in advance.

Regards,
Milan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Scott
Top achievements
Rank 1
answered on 03 Oct 2008, 02:09 PM
I have a page where I can select from 3 views - one view is a listbox, one is a RadGridView, and one is a ListBox wrapped around a RadCarouselPanel.  When I click to change the view, I get the ItemSource and bind it to the appropriate control (ListBox, RadGridView, or ListBoxCarousel).   If it's my Carousel view, I call a method that finds my path and sets the properties I want.

Within that method, I have a switch statement that lets me choose from different states.  I can collapse all the views to the left of the screen when I choose an item in them.  So I check the state of it and set the ItemsPerPage to a lower number when collapsed, and a higher number when full screen.  What I was doing before was defaulting it at the top of my method to be 19.  Then, if collapsed, I overlaid that property with 5.  It worked fine as long as I was always in my view screen, 19 items view.  When I collapsed and it went to 5 items, it correctly showed 5 items in the Carousel, but if I select any of them, it blew up on index out of range.

So my solution was to not default it at 19, but set it to 19 when I was full screen, and set it to 5 when I was collapsed.  If I switch it back to the previous way where I initialize it to 19, it failed again.   I'm not rebinding between these views, just changing their items per page.  But somehow, when overlaying that property, it messed up the listbox underneath.

That's the best explanation I can come up with.  It works fine now.
0
Milan
Telerik team
answered on 07 Oct 2008, 10:53 AM
Hi Scott,

Thanks for the detailed explanation. We will now try to reproduce the exception and fix the problem.

Best wishes,
Milan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Carousel
Asked by
Scott
Top achievements
Rank 1
Answers by
Milan
Telerik team
Scott
Top achievements
Rank 1
Share this question
or