我有两个名为ucA
和ucB
的UserControl,并且在'SomeWindow.xaml'中有一个滚动查看器。在scrollviewer中,我有一个ItemControl,以便可以使用数据绑定。在ItemControl中,我想配置一个触发器,以便通过设置对DataTrigger的绑定,在ItemControl中显示不同的UserControl。我该怎么办?
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<ItemsControl ItemsSource="{Binding SomeMember1}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding SomeMember2}" Value="0">
<uc:ucA /> <!-- What should be the actual code?-->
</DataTrigger>
<DataTrigger Binding="{Binding SomeMember2}" Value="1">
<uc:ucB /> <!-- What should be the actual code?-->
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>