Reputation: 5534
I have a maui ListView
binded to ObservableCollection
, I expect when I add a new element to the collection my ListView automatically scrolls to that new Item.
But instead my ListView
doesn't update itself,
I added a CollectionChanged event on my code behind (trying to achieve this), and make a manually scroll when item added but no when I run
LstItems.ScrollTo(e.NewItems[e.NewItems.Count - 1], ScrollToPosition.End, false);
My ListView goes to the end but it rebuilds all the entire ListView as you can see at Adding New Item to ListView
I tryed changing CachingStrategy
to: RecycleElement
, RetainElement
but same result.
I tryed using ScrollToPosition
to MakeVisible
But same result.
I tryed setting to false the Animation parameter of ScrollTo
But same result.
My questions:
ListView
automatically scrolls to the
new added item? If not:Upvotes: 3
Views: 2644
Reputation: 13879
You can try to use CollectionView to achieve this.
You can scroll to the last item by using the following code:
mCollectionView.ScrollTo(myViewModel.Items.Count - 1, animate: true);
For more about this, you can check: Scroll to End.
Upvotes: 2