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

ListView ScrollTo is not scrolling correctly

$
0
0

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;

Viewing all articles
Browse latest Browse all 91519

Trending Articles



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