Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the border colors of a WPF combobox

So I am trying to change the style of my combobox in Expression blend.

What I did was create a combobox, and went RightClick > Edit Template > Edit a Copy

And I can change the colors of the combobox, except there is a white border in between the background of the combobox, and the border of the combobox. Here is a screen so you can see:

enter image description here

As you can see, there is a while border between the blue and red. As far as I can tell, the code to change the color of combobox is the following:

<ToggleButton Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, 
RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource 
ComboBoxReadonlyToggleButton}" BorderBrush="Red" Background="Blue"/>

But no matter what, there is always a white border. How do i get rid of it?

like image 545
Toadums Avatar asked Jul 17 '12 18:07

Toadums


1 Answers

I know this is an old question, and it's specific to blend but when googling for this problem, this is one of the first things I found.

A really simple example of a way to fix this, that is a little less complex than the first answer mentioned is to set "Style" Properties. (Not sure this applies to blend since I don't use blend, but for simple wpf in visual studio, this works)

For example, this code below creates a window just like the one mentioned in the question, but with the white lines (in the drop down items) editable.

<ComboBox Background="Blue" BorderBrush="Red">
    <ComboBox.ItemContainerStyle>
        <!-- Without this style section, there are white lines around the borders.  Even if you set these properties in the comboBoxItem areas -->
        <Style TargetType="ComboBoxItem">
            <Setter Property="Background" Value="Green"/>
            <Setter Property="BorderBrush" Value="Purple"></Setter>
        </Style>
     </ComboBox.ItemContainerStyle>
     <ComboBoxItem MouseMove="schedule" Name="cbi1">schedule</ComboBoxItem>
</ComboBox>
like image 112
trueCamelType Avatar answered Sep 21 '22 13:09

trueCamelType