Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"inherit" style of theme in wpf

Tags:

styles

wpf

xaml

I'm using one of the themes in CodePlex and I want to add some modifications on the style but not to change their code. How can I inherit the theme style?

like image 784
Chen Kinnrot Avatar asked Jul 25 '09 15:07

Chen Kinnrot


1 Answers

<Style x:Key="Style1">
  <Setter Property="Control.Background" Value="Yellow"/>
</Style>

<Style x:Key="Style2" BasedOn="{StaticResource Style1}">
  <Setter Property="Control.Foreground" Value="Blue"/>
</Style>

MSDN reference: http://msdn.microsoft.com/en-us/library/system.windows.style.basedon.aspx

Another example (basing a style on a style with no explicit key):

<Style x:Key="Style3" BasedOn="{StaticResource {x:Type ComboBox}}">
  <Setter Property="Control.Foreground" Value="Blue"/>
</Style>

Just load the extending resource dictionary after the base resource dictionary via XAML or code.

like image 185
Danny Varod Avatar answered Oct 15 '22 14:10

Danny Varod