If you want your ListBox
to only fit 10 items, having to scroll for the rest, you can simply set the height of ListBoxItem
s to be the height of the ListBox
divided by 10.
If you want to allow the ListBox
to resize, you will have to adjust the ListBoxItem
height dynamically on each resize event.
Static example:
<ListBox Height="500">
<ListBox.Resources>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Height" Value="50"/>
</Style>
</ListBox.Resources>
<ListBoxItem>One</ListBoxItem>
<ListBoxItem>Two</ListBoxItem>
<ListBoxItem>Three</ListBoxItem>
<ListBoxItem>Four</ListBoxItem>
<ListBoxItem>Five</ListBoxItem>
<ListBoxItem>Six</ListBoxItem>
<ListBoxItem>Seven</ListBoxItem>
<ListBoxItem>Eight</ListBoxItem>
<ListBoxItem>Nine</ListBoxItem>
<ListBoxItem>Ten</ListBoxItem>
<ListBoxItem>Eleven</ListBoxItem>
<ListBoxItem>Twelve</ListBoxItem>
<ListBoxItem>Thirteen</ListBoxItem>
<ListBoxItem>Fourteen</ListBoxItem>
<ListBoxItem>Fifteen</ListBoxItem>
<!-- etc. -->
</ListBox>