ボタンのリストを生成するために、2 つの異なる ItemsControl を使用しています。
<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>
2 番目の ItemsControl のボタンが新しい「行」に表示されます
2番目のItemsControlのボタンが最初のItemsControlのボタンの直後に表示される可能性はありますか? ボタンの数は異なる場合があります。次のようになります。