-
Notifications
You must be signed in to change notification settings - Fork 1.9k
CollectionView.Scrolled event offset isn't correctly reset when items change on Android #21708
Description
Description
When changing the contents of the CollectionView.ItemsSource while scrolled down into the list, ItemsViewScrolledEventArgs.VerticalOffset is not correctly updated in Android.
Offset "0" should be at the start of the collection; instead the start offsets changes as items are added/removed. It manifests only when the collection is scrolled to after the position of the added/deleted items.
This issue was known and fixed in Xamarin.Forms: xamarin/Xamarin.Forms#7993 . It has reappeared in MAUI.
The repro app is adapted from the Xamarin issue.
Steps to Reproduce
- Start repro app on Android (device or simulator).
- Use "Fill" button to populate the list
- Scroll down the list
- Use "Empty" button to clear the list.
- Use "Fill" button again.
- Scroll down and up the list; the start offset is not 0 as it should be.

Link to public reproduction project repository
https://github.com/nshtinkov/MauiScrollOffsetAndroidBug
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
Replacing the ItemsSource collection after change seems to work, e.g. in the repro app:
private void EmptyButton_OnClicked(object sender, EventArgs e)
{
_items.Clear();
Items = new ReadOnlyObservableCollection<int>(_items);
}
Relevant log output
No response