diff --git a/src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs b/src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs
index 6cf8f41d9894..9239d5302eab 100644
--- a/src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs
+++ b/src/Controls/src/Core/Handlers/Items/Android/MauiCarouselRecyclerView.cs
@@ -320,7 +320,13 @@ void UpdateInitialPosition()
Carousel.Position = position;
}
else
+ {
position = Carousel.Position;
+ if (Carousel.Loop && position == 0)
+ {
+ itemCount = ItemsViewAdapter.ItemsSource.Count;
+ }
+ }
_oldPosition = position;
diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldScrollToRightPosition.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldScrollToRightPosition.png
new file mode 100644
index 000000000000..abcdf78d51d4
Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/CarouselViewShouldScrollToRightPosition.png differ
diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue17283.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue17283.xaml
new file mode 100644
index 000000000000..a0adb5ddcbb2
--- /dev/null
+++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue17283.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue17283.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue17283.xaml.cs
new file mode 100644
index 000000000000..b411a6552983
--- /dev/null
+++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue17283.xaml.cs
@@ -0,0 +1,63 @@
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+
+namespace Maui.Controls.Sample.Issues
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ [Issue(IssueTracker.Github, 17283, "[Android] CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled", PlatformAffected.Android)]
+ public partial class Issue17283 : ContentPage
+ {
+ public Issue17283()
+ {
+ InitializeComponent();
+ BindingContext = new Issue17283ViewModel();
+ }
+ }
+
+ public class Issue17283ViewModel : INotifyPropertyChanged
+ {
+ ObservableCollection _items;
+ public ObservableCollection Items
+ {
+ get => _items;
+ set
+ {
+ _items = value;
+ OnPropertyChanged();
+ }
+ }
+
+ int _position;
+ public int Position
+ {
+ get => _position;
+ set
+ {
+ _position = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public Command ReloadItemsCommand { get; set; }
+ public Command GoToLastItemCommand { get; set; }
+
+ public Issue17283ViewModel()
+ {
+ Items = new ObservableCollection { "1", "2", "3", "4", "5" };
+ ReloadItemsCommand = new Command(ReloadItems);
+ GoToLastItemCommand = new Command(() => Position = Items.Count - 1);
+ }
+
+ async void ReloadItems()
+ {
+ var currentPosition = Position;
+ Items = new ObservableCollection { "1", "2", "3", "4", "5last" };
+ await Task.Delay(300);
+ Position = currentPosition;
+ }
+ public event PropertyChangedEventHandler PropertyChanged;
+ void OnPropertyChanged([CallerMemberName] string propertyName = "") =>
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue17283.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue17283.cs
new file mode 100644
index 000000000000..22292eb845ce
--- /dev/null
+++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue17283.cs
@@ -0,0 +1,28 @@
+#if !MACCATALYST
+using NUnit.Framework;
+using UITest.Appium;
+using UITest.Core;
+
+namespace Microsoft.Maui.TestCases.Tests.Issues
+{
+ internal class Issue17283 : _IssuesUITest
+ {
+ public override string Issue => "[Android] CarouselView doesn't scroll to the right Position after changing the ItemSource with Loop enabled";
+
+ public Issue17283(TestDevice testDevice) : base(testDevice) { }
+
+ [Test]
+ [Category(UITestCategories.CarouselView)]
+ [FailsOnWindows("Currently fails on Windows; see https://github.com/dotnet/maui/issues/24482")]
+ public void CarouselViewShouldScrollToRightPosition()
+ {
+ App.WaitForElement("goToLastItemButton");
+ App.Click("goToLastItemButton");
+ App.WaitForElement("5");
+ App.Click("reloadItemsButton");
+ App.WaitForElement("5last");
+ VerifyScreenshot();
+ }
+ }
+}
+#endif
\ No newline at end of file
diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CarouselViewShouldScrollToRightPosition.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CarouselViewShouldScrollToRightPosition.png
new file mode 100644
index 000000000000..74140b51176e
Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/CarouselViewShouldScrollToRightPosition.png differ