我使用MetroDark主题。
我在xaml中使用此代码:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Theme/MetroDark/MetroDark.MSControls.Core.Implicit.xaml" />
<ResourceDictionary Source="Theme/MetroDark/MetroDark.MSControls.Toolkit.Implicit.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type Label}" >
<Setter Property="FontFamily" Value="B titr" />
<Setter Property="FontSize" Value="13" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style TargetType="{x:Type TextBox}" >
<Setter Property="FontFamily" Value="B Nazanin" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
</ResourceDictionary>
</Application.Resources>
字体系列已正确更改,但背景颜色也已更改。
我只想更改字体系列和字体大小,以及其他属性(例如:背景,边框等),并从默认主题(MetroDark)获得效果。
我该怎么做?
答案 0 :(得分:0)
在BasedOn
属性中设置基本样式,如下所示:
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}">
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
这种方式自定义样式从基本样式继承所有设置,并可以覆盖其中的一些