简体   繁体   中英

“inherit” style of theme in wpf

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?

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM