I used 3 days on this problem, so i ask here.
I have a listbox which contains some receipt items. when i add first couple of items everything works fine :
but as soon as an item is added to listbox which "overflow" scrollviewer, random margin suddenly appears and i cant figure out how to get rid of it:
I tried different versions of .NET framework and in 4.5 this doesnt happen, but unfortunatly i am bound to .NET 3.5
Here is a link to "sandbox" application with same behavior : link
Does anybody have any ideas?
Here is requirements:
You have set CanContentScroll="True"
on ScrollContentPresenter
which means you want item by item scrolling. If you set CanContentScroll="False"
you won't see any empty space at bottom. Reason being now listBox will use pixel by pixel scrolling.
With item scrolling, listbox reserve some space to make sure next item comes perfectly in viewport. Hence, you see empty space at bottom.
However, setting it to false will disable UI virtualization. So, it's a kind of trade off between empty space and virtualization.
That being said, you mentioned that it's working fine in .Net4.5 which is not the case. I tried in your sample with 4.5 also and still the same result.