WPF combobox loses Aero theme when using a style trigger
- by Greg R
I am using style triggers to change combo box to texbox if it's readonly, but for some reason when I apply the style, it cause the combobox theme to change from Aero to Windows Classic (the theme I currently have in use on my PC). Can I avoid this somehow? Here is my code:
<ComboBox ItemsSource="{Binding Source={StaticResource AllCountries}}"
SelectedValue="{Binding OrderInfoVm.BillingCountry}" DisplayMemberPath="Value"
SelectedValuePath="Key" IsReadOnly="{Binding ReadOnlyMode}"
Style="{StaticResource EditableDropDown}" />
<Style x:Key="EditableDropDown" TargetType="ComboBox">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="SelectedValuePath" Value="Content" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<TextBox Text="{TemplateBinding SelectedValue, Converter={StaticResource StringCaseConverter}}"
BorderThickness="0"
Background="Transparent"
FontSize="{TemplateBinding FontSize}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
FontFamily="{TemplateBinding FontFamily}"
Width="{TemplateBinding Width}"
TextWrapping="Wrap"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>