ListView scrollto method makes the list disappear and reappear

SmeSme USMember ✭✭✭

Hello, I am having an issue with ListView's scrollto method (to scroll to the bottom of the list). Essentially I have a 'chat room', so the user enters a message and it gets added to the observable collection that is bound to the listview. Without using the scrollto method, the new item in the collection appears just as it should. But when I use the scrollto method, everytime a new item gets added to the collection, the entire listview disappears briefly, then reappears with the newly added item. It is scrolling to the bottom of the list just fine, but I don't want it to disappear/reappear everytime a new item is added.

Heres the code I'm using, its placed in the Entry's "Completed" event handler (the entry allows the user to type the message that will get added to the listview)

var v = ListChatMessages.ItemsSource.Cast<ChatItemTemplate>().LastOrDefault();
ListChatMessages.ScrollTo(v, ScrollToPosition.End, false);


  • SmeSme USMember ✭✭✭
    edited September 2016

    After a bit more fiddling, I solved the problem by moving the above code into ListView's ItemAppearing event handler. However, even with adding 'true' for the animation parameter in the ScrollTo method, the listview is not smoothly scrolling, but rather 'jumping up' when a new item is added. Is there a way maintain the smooth animation of scrolling instead of jumping?

    Also, I notice it is scrolling to the bottom of the list before the latest item is added. In other words, It scrolls to the bottom, and at that time the item has not yet appeared, and then it appears after the scrolling (or rather, jumping) takes place. Is there a way to do the scrolling AFTER the new item is drawn on the screen? I would assume it would then scroll smoothly to the bottom of the list.

    I guess in short, where is the best place to put the ScrollTo method?

  • RaymondKellyRaymondKelly USMember ✭✭✭

    This is a bug in XF. Waiting months on this bug and no workaround exists. See these 2 bugs:

    It works if you turn off Uneven rows, but in my case, thats not an option.

  • SmeSme USMember ✭✭✭

    Actually its working, but only in UWP. Not working in Android (haven't tested iOS)

  • DeveloperODCDeveloperODC USMember ✭✭
    edited November 2016

    Thanks a lot, it works! I have added the scroll code in the UI thread, due to which the jumping effect has gone away.

    It works as intended.

    Overall, better than the whole listview getting refreshed.

    Thanks a lot, again!

    Platform: Windows 8.1(not UWP)

  • MuthuramMuthuram Member ✭✭
    edited February 2019

    hi @DeveloperODC @Sme i am also facing same issue in chat , if u solve that issue kindly share that part

Sign In or Register to comment.