我有一个VirtualizingStackPanel
来自ItemsSource
的商品。有多个项目而不是空格来显示VirtualizingStackPanel
中的所有项目。
示例:我有5.3件物品的空间,但我有7件物品。现在我希望VirtualizingStackPanel
显示5个项目并隐藏其余项目。
问题:面板显示6项。最后一项是溢出的。
在这种情况下,是否只能显示5个项目(=无溢出项目),只能使用XAML?
我的StackPanel的当前代码:
<ItemsControl ItemTemplate="{StaticResource rpTemplate}" ItemsSource="...">
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl>
我的DataTemplate:
<DataTemplate x:Key="rpTemplate">
<Label Content="{Binding Name}" HorizontalAlignment="Left" />
</DataTemplate>
它不一定是VirtualizingStackPanel
,它可以是StackPanel,DockPanel,等等,只要我可以列出项目。
答案 0 :(得分:0)
我找到了3个解决方案:
第一个(评论中提到Rachel)是using a converter。
第二个(我发现这是最简单的):make a new class inherited from my Panel and use that
我尝试了第三种解决方案并找到了Blend behaviors
的解决方案