Search code examples
c#.netxamlxamarinmaui

How to keep CollectionView from resetting its scroll position to beginning .NET MAUI


When CollectionView is reassigned it resets its scroll position back to beginning. for example i have a search function that when typed in filters the current CollectionView itemsSource to a new list and then assigns this as the new itemsSource it works but when i reassign the original itemsSource The CollectionView's scroll position resets to beginning. i guess it makes sense but how do i keep it from doing that?

I've tried looking through its properties to perhaps find something that would give me the current position its scrolled to so i can manually scroll to that position after it resets using its ScrollTo function but i didn't find anything.

is there anyway? how can i find the current scroll position of CollectionView?


Solution

  • It is not answer to your question, but hear me out.

    You can use two different controls.

    One permanent, and one changing, with assigned commands (for example tap gesture) pointing to the same code, and display the appropriate one.

    I have not used it for CollectionView precisely, but for very similar situation.

    Performance issues aside, this is a powerful option. And most importantly - a working one for containers. Considering that the childs do not take the state of the parent right now...