tags:

views:

286

answers:

1

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?

+6  A: 
<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.

Danny Varod
and what can i do if base style have no key? like in themes??????
Chen Kinnrot
All style have keys, the keys are either an ID e.g. "Style1" or an implicit or explicit Control type e.g. "BasedOn="{StaticResource {x:Type ComboBox}}"
Danny Varod
+1, This is the solution
Bryan Anderson