我的组合框唯一不起作用的部分是背景色。我希望整个事情都变黄。但是塌陷的部分仍然只是灰色。
<ComboBox Height="25" Width="125" Background="Yellow">
<ComboBox.ItemContainerStyle>
<Style TargetType="ComboBoxItem">
<Setter Property="Background" Value="Yellow"/>
<Setter Property="BorderBrush" Value="Yellow"/>
</Style>
</ComboBox.ItemContainerStyle>
<ComboBoxItem Content="One"/>
<ComboBoxItem Content="Two"/>
<ComboBoxItem Content="Three"/>
</ComboBox>
在Windows 7上使用wpf时,您的代码应该可以按预期工作。但是,如果您运行的是Windows 8或更高版本,则可能不适用。
这https://blog.magnusmontin.net/2014/04/30/changing-the-background-colour-of-a-combobox-in-wpf-on-windows-8/可能会帮助你实现你想要什么。
作者对此给出了很好的解释。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句