I'm using the Virtualizing WrapPanel in a ListBox. When the source collection of the ListBox changes, the ScrollInfo of the WrapPanel doesn't get reset. This is noticable when you fill the ListBox with too many items to display on screen, so a scrollbar
is visible, then scroll down a bit, then try to load only 1 item in the ListBox, which causes that item not to be displayed, because the WrapPanel is still scrollled to a position in which the top items are not visible.
- Fill the ListBox with a lot of items
- Scroll down
- Fill the ListBox with 1 item
=> item is invisible and scrollbar is not displayed.
I fixed this by changing your OnItemsChanged function to this:
protected override void OnItemsChanged(object sender, ItemsChangedEventArgs args)
this.offset.X = 0;
this.offset.Y = 0;