I have a VirtualizingStackPanel
with items from an ItemsSource
. There are more items than space to display all the items in the VirtualizingStackPanel
.
Example: I have space for 5.3 items but i have 7 items. Now i want the VirtualizingStackPanel
to show 5 items and hide the rest.
Problem: The panel shows 6 items. The last item is overflowing.
Is it possible to show only 5 items (= no overflowing items) in this case, only with XAML?
The current code of my StackPanel:
<ItemsControl ItemTemplate="{StaticResource rpTemplate}" ItemsSource="...">
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl>
And my DataTemplate:
<DataTemplate x:Key="rpTemplate">
<Label Content="{Binding Name}" HorizontalAlignment="Left" />
</DataTemplate>
It don't have to be VirtualizingStackPanel
, it can be a StackPanel, DockPanel, whatever, as long as i can list the items.