views:

929

answers:

1

Hello

I am trying to work out a style for a combo box 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).

How can I do that?

Cheers,
Berryl

     <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 code to set the controlTemplate?

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

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

Jobi Joy
I don't really get ControlTemplates yet I guess. The target type in that example was a ToggleButton, which got me an exception in the xaml designer. Changing it to a ComboBox seems to have turned the whole control white. Is there something simple I can do to fix that (please see edited code)? Thanks
Berryl
If you have Expression Blend, just right-click and choose Edit Template -> Edit a Copy (I think those are right names). Otherwise you should use Reflector with the BamlViewer add-in to get the XAML out of PresentationFramework.Aero.dll, and clip out the parts you need.
Ray Burns
The problem with your edited template is it doesn't have all of ComboBox's other features. When you look at the Microsoft-supplied template you'll see it is rather complicated. Copy their code and make the change you need.
Ray Burns