locked
Stop ListView scrolling when items are added to data source

    Question

  • I have a ListView binded to an ObservableCollection. My issue occurs when the user has scrolled the top of the ListView and then new data is added in at the head of the ObservableCollection.

    The ListView automatically scrolls to display the new items causing the user to loose their place.

    How can I insert new item into the ObservableCollection whilst retaining the users position when they are at the top of the list?

    Wednesday, October 22, 2014 4:40 PM

Answers

  • Hi BradSteveson,

    Let's say if following scenario can help you:

    1, Before update the ObservableCollection, record the current ListView scroll position. In your scenario, it could be the first item of the ListView.

    2, Update the data.

    3, Use ScrollIntoView(Object) method to scroll the ListView to original place, now the original first item could probably be six or seven item, anyway, just fill in the object.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 23, 2014 2:53 AM
    Moderator

All replies

  • Hi BradSteveson,

    Let's say if following scenario can help you:

    1, Before update the ObservableCollection, record the current ListView scroll position. In your scenario, it could be the first item of the ListView.

    2, Update the data.

    3, Use ScrollIntoView(Object) method to scroll the ListView to original place, now the original first item could probably be six or seven item, anyway, just fill in the object.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, October 23, 2014 2:53 AM
    Moderator
  • Hi this does work but is not ideal as the user sees the list update then scroll back.

    Is there a way to use ScrollIntoView without animating the scroll ? or preferably just to disable the behaviour when adding an item

    Saturday, November 08, 2014 2:36 PM