ListView, mantain scroll position when refresh

MirkoLongaMirkoLonga USMember ✭✭

Hi all, is it possible to mantain the current position of a ListView when some items are inserted on top of the ItemsSource?

Something like this
CurrentList.Insert (0, postsGrouped)
refresh the UI but moves the current position to the first element.

Thanks

Best Answer

Answers

  • AmitGobare23AmitGobare23 USMember ✭✭
    edited September 2016

    @AdamP I tried code which link you posted.....but there is not any class of name "Foo" or not code for class "Foo" .... so can you add that method....i am looking exactly same which you posted....thanks in advance:)

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @AmitG - there is no class called Foo, it is just an example to what your class would be called. For example if you had a list of Animal e.g. List you would replace Foo with Animal.

  • RianDutraRianDutra USMember ✭✭

    @AdamP there is no way to do it without ScrollTo?

    For example, on WhatsApp, when we scroll the listview top, it loads old messages, but the listview maintain the same position, withou scrolling it.

  • DavidDancyDavidDancy AUMember ✭✭✭✭

    If you bind a ObservableCollection<T> to your ListView's ItemsSource, you can just insert / delete elements in the collection and the ListView will insert / delete cells on screen to match. Depending on what gets inserted / deleted there may be a small amount of scrolling necessary but if the inserted / delete cell is visible on screen that should be pretty minimal.

Sign In or Register to comment.