SfListView ScrollTo On Source Change Not Working

I have followed the Syncfusion documentation to keep scroll position when the ItemsSource is changed at runtime but the SfListView isn't scrolling to the correct position (Link Here). I'm getting the correct ScrollY position but when the bindable.ScrollTo() method is ran with the correct scrollY parameter being passed in, I'm not getting the expected results. On iOS, the application crashes and on android the SfListView returns to the top instead of the correct scrollY position.


1 Reply

AK Ananthalakshmi Kannan Syncfusion Team November 6, 2023 02:49 PM UTC

Hi Bryson Scales,


Instead of passing the scrollview.ScrollY directly as a parameter to listView.ScrollTo, try storing the value of scrollview.ScrollY in a variable. Refer the code snippet below:


var scrollPosition = scrollview.ScrollY;

listView.ScrollTo(scrollPosition);


By storing the scrollview.ScrollY value in a variable before passing it to listView.ScrollTo, you can ensure that you're providing a valid and consistent scroll position value, which leads to the expected behavior of maintaining the scroll position after changing the ItemsSource of the SfListView.


I have attached the working sample for your reference. Both in Android and iOS, the sample works as expected.


Attachment: 185181Scroll_af9b7611.zip

Loader.
Up arrow icon