WPF Combobox
-
Hi I am trying to change the look of the ComboBox when it is disabled. I want to change it's background and border. I tried the most common aproach with triggers but that did not work. Than I tried changing the template but could not find the part that should be changed. Does anybody has a solution for my problem? Any advice will be appreciated. Uros
-
Hi I am trying to change the look of the ComboBox when it is disabled. I want to change it's background and border. I tried the most common aproach with triggers but that did not work. Than I tried changing the template but could not find the part that should be changed. Does anybody has a solution for my problem? Any advice will be appreciated. Uros
Try this:-
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="2"
CornerRadius="2"
Background="Red"
BorderBrush="Green"/>
<Border
Grid.Column="0"
CornerRadius="2,0,0,2"
Margin="1"
Background="Yellow"
BorderBrush="Black"
/>
<Path
Grid.Column="1"
Fill="Aqua"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>In XAML:-
hth, v
-
Try this:-
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Border
Grid.ColumnSpan="2"
CornerRadius="2"
Background="Red"
BorderBrush="Green"/>
<Border
Grid.Column="0"
CornerRadius="2,0,0,2"
Margin="1"
Background="Yellow"
BorderBrush="Black"
/>
<Path
Grid.Column="1"
Fill="Aqua"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 4 4 L 8 0 Z"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>In XAML:-
hth, v
Thanks for your reply - it works great. Maybe just one more thing. ComboBox with this style doesn't show the selected item(text) when disabled. I tried adding a TextBlock to one of the border's but I don't know to what should be bind to. Any ideas? Thanks again for your help. Uros