Skip to content

KeepLastItemInView not working on iOS #18029

@imsam67

Description

@imsam67

Description

The KeepLastItemInView doesn't seem to be working on iOS.

I have a bunch of items in a CollectionView which gets its data from an ObservableCollection in a view model. I then add a new item to ObservableCollection but the CollectionView doesn't display the newly added item. I have to manually scroll to see it.

This is happening in .NET 8 RC 2 but I observed the same behavior in .NET 7.

Here's the XAML:

...
<CollectionView
   ItemsSource={Binding FeedItems}
   ItemsUpdatingScrollMode="KeepLastItemInView">
   ...
</CollectionView>

And here's the view model:

public ObservableCollection<FeedItem> FeedItems { get; } = new();

[RelayCommand]
async Task AddItem(FeedItem newItem)
{
   FeedItems.Insert(0, newItem);
}

Steps to Reproduce

  1. Add a CollectionView to a ContentPage
  2. Create a corresponding ViewModel
  3. Create an ObservableCollection as demonstrated above
  4. Bind the CollectionView to ObservableCollection as its ItemsSource
  5. Insert a new item to the ObservableCollection at index 0

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

Haven't found a work around yet other than Clear(); the ObservableCollection and add all the items -- including existing ones -- all over again.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-collectionviewCollectionView, CarouselView, IndicatorViewmigration-compatibilityXamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convertplatform/ioss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions