【发布时间】:2016-04-25 21:19:27
【问题描述】:
我有一个名为Styles.xaml 的样式表,它包含所有初始样式,但随着时间的推移变得如此混乱。现在我要介绍第二种样式,称为Styles2.xaml,我想将颜色元素从Styles.xaml 移动到Styles2.xaml,并让Styles.xaml 引用来自Styles2.xaml 的颜色元素
【问题讨论】:
标签: c# wpf windows xaml windows-phone-8
我有一个名为Styles.xaml 的样式表,它包含所有初始样式,但随着时间的推移变得如此混乱。现在我要介绍第二种样式,称为Styles2.xaml,我想将颜色元素从Styles.xaml 移动到Styles2.xaml,并让Styles.xaml 引用来自Styles2.xaml 的颜色元素
【问题讨论】:
标签: c# wpf windows xaml windows-phone-8
您使用 MergedDictionary 语法添加对它的引用,假设下面的代码来自 Style2.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Kliva.XAMLResources">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Name="KlivaButton"
TargetType="Button">
<Setter Property="Background" Value="{StaticResource KlivaDarkBrush}" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontFamily" Value="{StaticResource OpenSansFontLight}" />
<Setter Property="FontSize" Value="22" />
</Style>
</ResourceDictionary>
【讨论】: