我如何得到一个白色的WPF ComboBox DropDown箭头颜色? [英] How do I get a white WPF ComboBox DropDown arrow color?
问题描述
我想为 ComboBox
制作一个有白色文字海军背景的样式,所以我想下拉箭头也是白色的(xaml
I am trying to work out a style for a ComboBox
that has a navy background with white text, so I want the drop down arrow to be white also (the xaml I have so far is below).
<Style x:Key="ComboBoxStyle" TargetType="ComboBox">
<Setter Property="Background" Value="{StaticResource headerBrush}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="{StaticResource headerBorderBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="MinWidth" Value="100"/>
<Setter Property="Height" Value="21"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="Margin" Value="3"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>
<Style x:Key="ComboBoxItemStyle" TargetType="ComboBoxItem">
<Setter Property="Background" Value="AliceBlue"/>
<Setter Property="Foreground" Value="Navy"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
</Style>
ADDED代码设置 ControlTemplate
?
ADDED code to set the ControlTemplate
?
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Path x:Name="Arrow" Fill="White"/>
</ControlTemplate>
</Setter.Value>
</Setter>
推荐答案
您需要编辑ComboBox的ControlTemplate,看到箭头作为一条道路。因此,将路径的Fill属性更改为所需的箭头颜色。请参阅此处的示例ControlTemplate
http://msdn.microsoft.com/ en-us / library / ms752094.aspx
You need to edit the ControlTemplate of ComboBox and you can see a the Arrow as a Path. So change the Fill property of the Path to your desired arrow color. See sample ControlTemplate here http://msdn.microsoft.com/en-us/library/ms752094.aspx
这篇关于我如何得到一个白色的WPF ComboBox DropDown箭头颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!