我有一个项目控件,其来源包含72个项目,每显示一个按钮,它的源即可。我希望这些按钮的大小相等,并填满窗口的剩余空间。但是,当使用我当前的解决方案时,所有按钮都相互重叠,并且不会垂直占据整个空间。我不太确定自己在做什么错...任何帮助将不胜感激。
<ItemsControl Margin="10,60" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemsSource="{Binding Buttons}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="6" Columns="12"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Style="{Binding DataContext.DisplayLines, Converter={StaticResource MyButtonStyleConverter}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:DisplayView}}}" Command="{Binding DataContext.SendMessage, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:DisplayView}}}" CommandParameter="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
替换为:
<UniformGrid Rows="6" Columns="12"/>
使用此:
<WrapPanel />