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
2009-07-25 16:01:53
and what can i do if base style have no key? like in themes??????
Chen Kinnrot
2009-07-25 19:20:13
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
2009-07-25 20:17:01
+1, This is the solution
Bryan Anderson
2009-07-25 20:59:57