-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
🤔 pending discussionIt may take time to discuss.It may take time to discuss.
Description
Describe the bug
The carousel control crashes when it has no items initially and one adds items afterwards.
To Reproduce
- Add a carousel without any initial items
- Add an item (e.g. via code) once the view has been initialised.
- Crashes with an Out-of-bounds exception
Expected behavior
No crash.
Additional context
Debugging shows that Carousel.UpdateItemsPosition() is crashing once it tries to use the PageIndex, which is -1 at that point and therefore of course out-of-bounds.
Possible fix is to update the PageIndex to an in-bounds range value when an item is added.
private void UpdateItemsPosition()
{
if (!CheckNull() || !_appliedTemplate || Items.Count == 0)
return;
if (PageIndex == -1) // Fixes the crash
{
PageIndex = 0;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🤔 pending discussionIt may take time to discuss.It may take time to discuss.