
[英]How to adjust TableLayoutPanel to wrap content by height and weight? (dynamically)
[英]Wrap Content of ItemsControls
我正在使用两个不同的ItemsControl来生成Button列表。
<WrapPanel Orientation="Horizontal">
<ItemsControl ItemsSource="{Binding Commands}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Command="{Binding}">
<!-- ... -->
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl ItemsSource="{Binding CurrentTransaction.Modifiers}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ToggleButton IsChecked="{Binding IsEnabled}">
<!-- ... -->
</ToggleButton>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
第二项控件的按钮出现在新的“行”上
第二个ItemsControl的按钮是否可能直接出现在第一个ItemsControl的按钮之后? 按钮的数量可能会有所不同。 它看起来应该像这样:
您可以将两个项目集合合并为一个,并且只有一个ItemsControl和一个ItemTemplateSelector可以为每个项目返回适当的DataTemplate。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.