Reputation: 1337
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
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
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
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