WPF中的覆盖主题
我有一个小问题与wpf项目,我目前正在工作。我是WPF的新手。在我的app.xaml中,我将Microsoft Aero主题用于我的应用程序。我的app.xaml中有类似的东西WPF中的覆盖主题,wpf,xaml,themes,styles,Wpf,Xaml,Themes,Styles,我有一个小问题与wpf项目,我目前正在工作。我是WPF的新手。在我的app.xaml中,我将Microsoft Aero主题用于我的应用程序。我的app.xaml中有类似的东西 <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/PresentationFramework.Aero;V3.0.0.0
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/Aero.NormalColor.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
我不认为资源是静态的,因为它来自dll,它可能应该是这样的。不过我不确定
BasedOn="{DynamicResource {x:Type Button}}"
但上述情况会引发异常,如果我的app.xaml中有多个resourcedictionary,例如luna和classic,会怎么样。我如何知道使用哪一个作为默认值,同时针对ui中的某些控件使用并覆盖另一个控件(例如luna)?所以我的一些按钮将基于luna风格,一些基于aero风格,并进行进一步修改
有什么想法吗
关于您的具体问题, e、 g.对于按钮,我希望覆盖字体样式,同时保留aero样式的其余部分 我会尝试在您的资源字典中添加以下内容:
<FontFamily x:Key="YourFont">Tahoma</FontFamily>
Tahoma
然后在你的风格中使用:
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" x:Key="RedTextBasedOnButton">
<Setter Property="FontFamily" Value="{StaticResource YourFont}"/>
</Style>
因此,可以基于单个关键点更改FontFamily
我建议您查看此的可能副本。是否有任何样式具有可绑定的显式键?
<FontFamily x:Key="YourFont">Tahoma</FontFamily>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" x:Key="RedTextBasedOnButton">
<Setter Property="FontFamily" Value="{StaticResource YourFont}"/>
</Style>