如何获得白色WPF ComboBox DropDown箭头颜色?

时间:2009-11-09 04:29:50

标签: wpf combobox styles drop-down-menu

我正在尝试为具有白色文字的海军背景的ComboBox制作样式,所以我希望下拉箭头也是白色的(我到目前为止的xaml是在下面)。 / p>

  <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

<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="ComboBox">
            <Path x:Name="Arrow" Fill="White"/>
        </ControlTemplate>
    </Setter.Value>
</Setter>

1 个答案:

答案 0 :(得分:2)

您需要编辑ComboBox的ControlTemplate,您可以看到箭头作为路径。因此,将Path的Fill属性更改为所需的箭头颜色。请在此处查看示例ControlTemplate http://msdn.microsoft.com/en-us/library/ms752094.aspx