简体   繁体   English

在wpf中“继承”主题风格

[英]“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. 我正在使用CodePlex中的一个主题,我想在样式上添加一些修改但不要更改它们的代码。 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 MSDN参考: 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. 只需通过XAML或代码在基本资源字典之后加载扩展资源字典。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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