Closed IeuanWalker closed 1 day ago
My current workaround -
I have created a DataChanged
bool property in the view model, that i toggle whenever the ObservableCollection changes.
Then on the page code behind i have a property changed event that triggers a scroll too based on the DataChanged
viewModel.PropertyChanged += async (object? _, PropertyChangedEventArgs e) =>
{
if(e.PropertyName is null)
{
return;
}
if(e.PropertyName.Equals(nameof(viewModel.DataChanged)))
{
await Task.Delay(100);
itemCollectionView.ScrollTo(0);
}
};
Description
Currently the CollectionView ItemsUpdatingScrollMode, has 3 options -
KeepItemsInView
keeps the first item in the list displayed when new items are added.KeepScrollOffset
ensures that the current scroll position is maintained when new items are added.KeepLastItemInView
adjusts the scroll offset to keep the last item in the list displayed when new items are added.ItemsUpdatingScrollMode
A common use case for CollectionView is searching a collection -
And ideally every time the user searches for something you'd want to look at the top results. But currently using
ItemsUpdatingScrollMode
there is no way to achieve this.You can see what I mean in the following video. I search for the item at the bottom of the list, I then clear the search, but the scroll position is still stuck at the bottom, and the user has to scroll back up them selves https://github.com/user-attachments/assets/ad8ecd27-921d-4abe-82f6-d92ef0ae8a5b
Public API Changes
ItemsUpdatingScrollMode
has a new optionGoToStart
Intended Use-Case
see description