0
我正在构建一个工具来同时编辑多个数据库对象,并且很想让您对高亮方案有所了解。
在我的ViewModel
中,我有一个Juris
,Jurisdictions
的集合,这些集合与用户选择编辑的任何项目相关联。我还有一个由所有选定项目“CommonJuris”共享的辖区子集。我的问题是:是否有一种简单的方法可以用完整集合填充ListBox
,并突出显示子集合中的项目?
目前我有一个布尔属性,IsCommon
,在我的Jurisdiction Model
。我真的不想在Model
这个,但我还没有找到更好的解决方案。 Jurisdiction
没有ViewModel
,因为这是唯一的东西。WPF子组突出显示
这里是我的列表框本身的XAML:
<ListBox Grid.Row="1" Grid.Column="2" ItemContainerStyle="{StaticResource JuriAndTT}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
HorizontalContentAlignment="Stretch"
ItemsSource="{Binding Juris}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
而且款式:
<Style TargetType="{x:Type ListBoxItem}" x:Key="JuriAndTT">
<Style.Triggers>
<DataTrigger Binding="{Binding IsCommon}" Value="True">
<Setter Property="Background" Value="PowderBlue"/>
<Setter Property="Foreground" Value="Black"/>
</DataTrigger>
</Style.Triggers>
</Style>