title: ListBox, VirtualizingStackPanel, and Smooth Scrolling in WPF
body: <p>I have a <code>ListBox</code> that may have many rows of templated DB records, including an <code>Image</code>, bound to an <code>ObservableCollection&lt;MyItem&gt;</code>.  Sometimes the collection could hold thousands of items.</p>
  
  <p>The performance is great, but the scrolling is the default jumpy behavior.  I would like it to have smooth scrolling, so I unchecked <code>ScrollViewer.CanContentScroll</code>.</p>
  
  <p>Now I have smooth scrolling, but the performance is horrendous: the data is retrieved in a separate thread, and the thread finishes quickly, but it takes 10-20 seconds for the results to show in the <code>ListBox</code>.  I assume that this is because unchecking <code>ScrollViewer.CanContentScroll</code> changes the underlying <code>VirtualizingStackPanel</code> to a regular <code>StackPanel</code> and so it is loading the entire collection before displaying the results.</p>
  
  <p>So my question is this: how do I retain the the smooth scrolling without sacrificing the <code>VirtualizingStackPanel</code> behavior and performance?</p>