I have created a custom combo box control which inherits from Combobox class. There is a type style defined for ComboxBox type on ResourceDictionary which applied automatically for all combo boxes but this is not getting applied the custom control.
Style defined on App.xaml
<Application.Resources>
<Style x:Key="{x:Type ComboBox}" TargetType="{x:Type ComboBox}">
<Setter Property="Background" Value="Gray"/>
</Style>
</Application.Resources>
Custom ComboBox
public class AutoComboBox : ComboBox
MainWindow.xaml
<StackPanel Orientation="Vertical">
<ComboBox Width="200"/>
<local:AutoComboBox Width="200"/>
</StackPanel>
The first combo box will have Background as Gray color as the style defined on App.xaml is applied. But the second combo box still show the default background color.
Is there any way we can apply the same type style on custom control without creating duplicate style for custom control?
Style
set theTemplate
on eveyComboBox
- or if you want to apply it selectively give theStyle
a key. – markmnl