Reputation: 1857
I am using two different ItemsControl to generate a list of Buttons.
<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>
The buttons of the 2nd ItemsControl appear on a new "Line"
Is it possible that the Buttons of the 2nd ItemsControl appear directly after the Buttons from the first ItemsControl? The number of Buttons may vary. It should look like this:
Upvotes: 3
Views: 161
Reputation: 128181
You could merge the two item collections into one and have only one ItemsControl with an ItemTemplateSelector that returns the appropriate DataTemplate for each item.
Upvotes: 1