我想为 PASS
设置文本颜色如 GREEN
和 FAIL
的文本颜色如 RED
.我似乎无法找到解决方案。我需要在纯 XAML 中执行此操作。
<ComboBox x:Name="LocatedCorrectly" Width="100"
Height="25" Grid.Column="1" Grid.Row="2"
HorizontalAlignment="Left"
IsSynchronizedWithCurrentItem="True">
<ComboBoxItem Content="PASS" Tag="PASS" IsSelected="True"/>
<ComboBoxItem Content="FAIL" Tag="FAILED" />
</ComboBox>
最佳答案
您可以使用触发器相同(您也应该继承基本样式)
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Foreground" Value="Blue" />
<Style.Triggers>
<Trigger Property="Content" Value="PASS">
<Setter Property="Foreground" Value="Green"/>
</Trigger>
</Style.Triggers>
</Style>
关于wpf - 在 ComboBoxItem 中设置文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18478778/