我正在尝试将数据触发器添加到默认组合框样式,因此下拉框中的每个文本项都将被分配不同的颜色,并且所选项目也将是该颜色。通过使用此 xaml 代码,我已经成功地对我的数据网格中的文本列项进行了颜色编码:
<DataGrid ...>
<DataGrid.Columns>
<DataGridTextColumn ...>
<DataGridTextColumn.CellSyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Status}" Value="Accepted">
<Setter Property="Foreground" Value="Green"/>
</DataTrigger>
<Style.Triggers>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
但我无法弄清楚如何为组合框执行此操作。有人可以帮忙吗?