Hi developers,
I am using several ListView controls in my App, but the ScrollTo method is not working as aspected.
When I call the method to scroll to the last item in the list, the ListView is always scrolling to the item before the last.
I tried different parameters e.g. but the behavior was ever the same on Android (Other platforms I did not tested yet)
Here ist some simple code from one of my ContentPages:
var messageList = new ListView
{
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.FillAndExpand,
ItemTemplate = new DataTemplate(typeof(MessageChatCell)),
HasUnevenRows = true,
};
MessagingCenter.Subscribe<MessageChatViewModel, MessageChatItemModel>(this, "ChatListScrollToItem", (sender, model) =>
{
Device.BeginInvokeOnMainThread(() =>
{
if (model != null)
{
messageList.ScrollTo(model, ScrollToPosition.MakeVisible, true);
}
});
});
Content = messageList;