C# 如何水平限制项目数量,如果超过,则扩展到另一行?
请看下图: 所以我将从数据库中获取数据并绑定到一个列表。现在我的目标是确保最多只有6个项目,剩下的项目转到下一行C# 如何水平限制项目数量,如果超过,则扩展到另一行?,c#,wpf,scrollviewer,wrappanel,C#,Wpf,Scrollviewer,Wrappanel,请看下图: 所以我将从数据库中获取数据并绑定到一个列表。现在我的目标是确保最多只有6个项目,剩下的项目转到下一行请看看我目前的做法: <ScrollViewer> <ItemControl DataContext ="{Binding [SomeViewModel]}" ItemSource="{Binding printerList}"> <ItemControl.ItemTemplate> <Data
请看看我目前的做法:
<ScrollViewer>
<ItemControl DataContext ="{Binding [SomeViewModel]}" ItemSource="{Binding printerList}">
<ItemControl.ItemTemplate>
<DataTemplate>
<WrapPanel ItemWidth="100" Width="800" Orientation="Horizontal">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
<Image Source="{Binding printerImage}"/>
<TextBlock Text="{Binding PrinterName}"
</StackPanel>
</WrapPanel>
</DataTemplate>
</ItemControl.ItemTemplate>
</ItemControl
</ScrollViewer>
可以使用统一的网格
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="6"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>