Jean Tehhe
Jean Tehhe

Reputation: 1337

Change combo-box style and color

I have a combobox and I want to change its style and color. Should become white instead of gray. How should I do that?

I tried with OpacityMask = "White", which did not work for me..

Upvotes: 1

Views: 2311

Answers (4)

Sajeetharan
Sajeetharan

Reputation: 222522

For WPF:

var combo = new Combobox(); 
combo.Background = Brushes.White;
combo.Foreground = Brushes.Black;

Or you want to check Style Triggers:

<!-- Corrected XAML syntax. -->
<Style.Triggers>
  <Trigger Property="IsMouseOver" Value="true">
    <Setter Property="Background" Value="White" />
  </Trigger>
  <Trigger Property="IsEnabled" Value="false">
    <Setter Property="Background" Value="Black" />
  </Trigger>
</Style.Triggers>

Upvotes: 1

lusian_andrei
lusian_andrei

Reputation: 117

This style will be aplied to all your combo-boxes.

<Style x:Key="{x:Type ComboBox}" TargetType="{x:Type ComboBox}">
<Setter Property="Background" Value="White" /> 
</Style>

If you want in a specific combobox use:

<Style x:Key="ComboStyle" TargetType="{x:Type ComboBox}">
 <Setter Property="Background" Value="White" /> 
</Style>

For a complete template check MSDN

Upvotes: 1

John Jerrby
John Jerrby

Reputation: 1703

use the following Example

  <Style TargetType="ComboBox">

            <Setter Property="ComboBox.BorderBrush"
                    Value="LightSlateGray" />
            <Setter Property="ComboBox.Background"
                    Value="white" />
            <Style.Triggers>

Upvotes: 0

Tarec
Tarec

Reputation: 3255

Use BackgroundColor property for setting the color of that control.

Upvotes: 0

Related Questions