I have this ScrollViewer:
<ScrollViewer x:Name="myScrollViewer">
<ItemsControl x:Name="myItemsControl" ItemTemplateSelector="{DynamicResource myItemtemplateSelector}" ItemsPanel="{StaticResource myItemsPanel}" />
</ScrollViewer>
I fill the ItemsControl
with a class that has one boolean parameter. When it's true I want to call one ItemTemplateSelector
; and another one in the false case.
I'm trying something like that:
<ItemsControl x:Name="myItemsControl" ItemsPanel="{StaticResource myItemsPanel}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl>
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=myBoolean}" Value="False">
<Setter Property="ContentTemplate" Value="{DynamicResource SubdisciplineDataTemplateSelector}" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=myBoolean}" Value="True">
<Setter Property="ContentTemplate" Value="{DynamicResource SubdisciplineDataTemplateSelector2}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Is this the right way?