我有这个 ScrollViewer:
<ScrollViewer x:Name="myScrollViewer">
<ItemsControl x:Name="myItemsControl" ItemTemplateSelector="{DynamicResource myItemtemplateSelector}" ItemsPanel="{StaticResource myItemsPanel}" />
</ScrollViewer>
ItemsControl
我用一个具有一个布尔参数的类填充。如果是真的,我想打电话给一个ItemTemplateSelector
;还有一个是假的。
我正在尝试这样的事情:
<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>
这是正确的方法吗?