WPF Remove Extra Space on bottom of ListBox

Currently you are scrolling item by item.

The problem is because Test 5 in your listbox is the next item that would be displayed (and it's larger than the empty space shown in the picture you included). Only once that space is big enough for Test 5 to be fully displayed will it actually get shown.

However, if you want smooth scrolling instead of item by item scrolling, simply set the ScrollViewer.CanContentScroll property to false.

<ListBox ScrollViewer.CanContentScroll="False" ItemsSource="{Binding}" Width="320" Background="#FF021422" BorderBrush="#FF1C4B79" >

Hope that helps!


As a quick answer if someone comes around this in .Net 4.5

VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.ScrollUnit="Pixel" 

will do the trick. For better explanation look at: http://www.jonathanantoine.com/2011/10/07/wpf-4-5-%E2%80%93-part-11-new-features-for-the-virtualizingpanel/

Tags:

Wpf

Xaml

Listbox