У меня ItemControl определен так:
<ItemsControl ItemsSource="{Binding PageViewModels}">
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Style.Resources>
<Style TargetType="Button" x:Key="Big">
<Setter Property="Content" Value="BigStyle"/>
</Style>
<Style TargetType="Button" x:Key="Small">
<Setter Property="Content" Value="SmallStyle"/>
</Style>
</Style.Resources>
<Setter Property="Tag" Value="{StaticResource RoundCornerButtonMagentaFilledBig}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding PageViewModels.Count}" Value="2">
<Setter Property="Tag" Value="{StaticResource RoundCornerButtonMagentaFilledSmall}"/>
</DataTrigger>
<DataTrigger Binding="{Binding CurrentPageViewModel.Name}" Value="Home Page">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{Binding PageViewModels.Count}" Margin="0,19"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button x:Name="NavigationButton"
Content="{Binding Name}"
Command="{Binding DataContext.ChangePageCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding }"
Style="{Binding Tag, RelativeSource={RelativeSource FindAncestor, AncestorType=ItemsControl}}"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Это отображает сетку кнопок на основе параметра.Однако теперь я хочу, чтобы он отображал различные элементы управления в этой сетке.Например, если PageViewModesl.Count
равно 2, я хочу иметь сетку
КНОПКА КНОПКИ
Если это 3:
КНОПКА КНОПКИ КНОПКИ
Но, если это 4, я хочу иметь:
КНОПКА ТЕКСТА КНОПКА ТЕКСТА
Как я могу поместить туда различные элементы управления?