title: Prevent Unwanted ListView Scrolling When Item Height Changes
body: <p>I have a ListView in a UWP/Windows 10 app. The list view is bound to an observable collection, with each item in the collection implementing INotifyPropertyChanged for binding purposes.</p>
  
  <p>The items in the collection contain some immediatley available data, exposed via properties and bound by controls in the the data template. However some properties on the bound objects are lazy loaded - the data isn't available immediately when the item is added to the collection. Usually this data is sourced from the internet via HTTP calls. Sometimes the data is already being lazy loaded in the background when the item is added, sometimes the first call to the property (made by a control in the item data tempalte binding to it) causes a lazy load to start. When the lazy load completes the property changed event is raised, and the bound controls update with the new values and the screen updates. All of that works.</p>
  
  <p>The symptom I am getting is that when scrolling quickly, most often when repeatedly clicking or holding down the mouse button within the scroll bar area, the scrolling continues when the clicking stops. The list view continues to scroll in the direction the user was scrolling until it hits the end of the list.</p>
  
  <p>I believe the problem is caused by the item heights changing. When the lazy loaded data updates and the bindings re-occur, the visuals for them item grow (because invisible controls are now visible, or we can now determine the height of an image we had to download, or we've added long text to a textblock with word wrapping enabled etc). I think when some of the items change height, the listview scrolls for some reason. The scrolling may cause an item not yet scrolled to, to become realised (list is virtualised) which in turn causes more lazy loading, which updates the height and scrolls again, creating a sort of loop until the end of the list is reached. I am not sure if it is the height of visible or off-screen items changing that causes the issue. It might be that items earlier in the list resizing 'push down the top' of the visible items. Or it might be the items currently visible resizing cause the list to attempt to keep those items in view but is confused by the constantly changing heights. I do not know exactly what the scroll is occuring. </p>
  
  <p>I do know that if I disable the lazy loading, or do not raise the notifications so the data loading occurs but the item heights/visuals do not change the scrolling issue does not occur.</p>
  
  <p>Given I can't know the height of the items before I've retrieved the data, and I don't want to/can't wait for all the data to be retrieved upfront, can anyone think of a work around to avoid the continuous scrolling issue?</p>
  
  <p>Thanks in advance.</p>