Forum Xamarin.Forms

ListView.ScrollTo Animated false doesn't work

The code below works:
MessagesListView.ScrollTo(viewModel.Messages[viewModel.Messages.Count - 1], ScrollToPosition.MakeVisible, true);

However, if I set animated = false, it doesn't work, at least on Android:
MessagesListView.ScrollTo(viewModel.Messages[viewModel.Messages.Count - 1], ScrollToPosition.MakeVisible, false);

Nothing happens.
Any solution?



  • RyanDixonRyanDixon USMember ✭✭✭

    Just having a look at the code @ line 271:

    It seems like the only difference in behaviour is the use of the that call to "GetDistance" which creates the offset over 1000 ms to create the animation you see. Therefore the values being used and the methods being called should be identical...

    It could be a problem with the underlying Android kernel, have you tried this on another device or have you tried wrapping it in a Device.RunOnUIThread block to check if that could solve it?

  • ChaseLongChaseLong USUniversity ✭✭
    edited March 2017

    I have a similar problem. I call ListView.ScrollTo(, ScrollToPosition.Center, false) when the ListView's BindingContext changes to an object of a specific type. The BindingContext is set before the view is drawn. It works on iOS, but not on Android. I assume the scroll request is stored as a pending scroll in the Xamarin.Forms platform-specific ListView renderers, based on glancing at the source code, so maybe the pending scroll stuff is just not implemented correctly in the Android renderer.

    It does work if I delay calling ScrollTo until a few seconds after the BindingContext changes.

  • ChaseLongChaseLong USUniversity ✭✭

    I reported this bug, with a solution that reproduces the issue, at

Sign In or Register to comment.