diff --git a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Android.cs b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Android.cs index abe5e4b40480..159921a44d0a 100644 --- a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Android.cs +++ b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Android.cs @@ -43,6 +43,12 @@ public static void MapPeekAreaInsets(CarouselViewHandler handler, CarouselView c (handler.PlatformView as IMauiRecyclerView).UpdateAdapter(); } + // TODO: Change the modifier to public in .NET 10. + internal static void MapLoop(CarouselViewHandler handler, CarouselView carouselView) + { + (handler.PlatformView as IMauiRecyclerView).UpdateAdapter(); + } + public static void MapPosition(CarouselViewHandler handler, CarouselView carouselView) { (handler.PlatformView as IMauiCarouselRecyclerView).UpdateFromPosition(); diff --git a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs index 019796a0c899..caf0ccfc1469 100644 --- a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs +++ b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs @@ -21,7 +21,8 @@ public CarouselViewHandler(PropertyMapper mapper = null) : base(mapper ?? Mapper [Controls.CarouselView.PeekAreaInsetsProperty.PropertyName] = MapPeekAreaInsets, [Controls.CarouselView.IsBounceEnabledProperty.PropertyName] = MapIsBounceEnabled, [Controls.CarouselView.PositionProperty.PropertyName] = MapPosition, - [Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem + [Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem, + [Controls.CarouselView.LoopProperty.PropertyName] = MapLoop }; } } \ No newline at end of file diff --git a/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs b/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs index 0c111b4e865d..6723753a6d09 100644 --- a/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs +++ b/src/Controls/src/Core/Handlers/Items/iOS/CarouselViewController.cs @@ -440,6 +440,11 @@ void UnsubscribeCollectionItemsSourceChanged(IItemsViewSource oldItemsSource) internal void UpdateLoop() { + if (!InitialPositionSet) + { + return; + } + if (ItemsView is not CarouselView carousel) { return; diff --git a/src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs b/src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs index c8fa6fa50ba7..03628f25373b 100644 --- a/src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs +++ b/src/Controls/src/Core/Handlers/Items2/CarouselViewHandler2.iOS.cs @@ -29,6 +29,7 @@ public CarouselViewHandler2(PropertyMapper mapper = null) : base(mapper ?? Mappe [Controls.CarouselView.PositionProperty.PropertyName] = MapPosition, [Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem, [Controls.CarouselView.ItemsLayoutProperty.PropertyName] = MapItemsLayout, + [Controls.CarouselView.LoopProperty.PropertyName] = MapLoop }; } diff --git a/src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs b/src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs index ceb8065ff450..4ccda915a231 100644 --- a/src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs +++ b/src/Controls/src/Core/Handlers/Items2/iOS/CarouselViewController2.cs @@ -368,6 +368,11 @@ internal bool IsUpdating() } internal void UpdateLoop() { + if (!InitialPositionSet) + { + return; + } + if (ItemsView is not CarouselView carousel) { return; diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemsShouldRenderVertically.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemsShouldRenderVertically.png index 55c45a912d16..6bf5589c5031 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemsShouldRenderVertically.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewItemsShouldRenderVertically.png differ diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldRenderCorrectly.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldRenderCorrectly.png index bf3e23f5eedd..eb2e9cdb6705 100644 Binary files a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldRenderCorrectly.png and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldRenderCorrectly.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue29411.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue29411.xaml new file mode 100644 index 000000000000..a9928cad957d --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue29411.xaml @@ -0,0 +1,34 @@ + + + + + First + Second + Third + + + + + + + + + + + + + +