Overriding Control Theme in WPF
I was working on a skinned application using skinning feature of WPF. I had a ComboBox control that I wanted to select the overall theme of the application with. I also had created a new style for ComboBox control but I needed to keep this one’s style as default! When I set the whole application’s look and feel, this ComboBox naturally changed its theme too, which was not what I wanted.
The trick was very easy but it took me about an hour to find out! What I did to achieve this was to create a new style and inherit the style from the original style of ComboBox control. Later when the application’s run and the theme is applied, since this control has a specific style, will not get the custom style.
The ComboBox control specifying a style looked like this :
1 | <ComboBox Style="{StaticResource ThemeComboBox}" > |
And the style to inherit from the base control’s style :
1 | <Window.Resources> |