Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

How to scroll to last item in ListView

$
0
0

Hello. I'm using Forms 1.4.2.6359 and I have a ListView with HasUnevenRows = true. I'm trying to get the ListView to scroll to the last item in the list after its ItemSource is asynchronously populated after the view initially loads, but I'm not sure it's working as expected. I should also mention that the row heights vary widely.

Is there anything wrong with the following code -- am I using the ListView.ScrollTo method incorrectly or am I missing something here?

public Task NotifyDataLoadedAsync ()
{
    var lastMessage = this.MessagesListView.ItemsSource.Cast<object> ().LastOrDefault ();
    if (null != lastMessage) {
        this.MessagesListView.ScrollTo (lastMessage, ScrollToPosition.End, true);
    }

    return Task.FromResult (0);
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>