0
我有一个名为Styles.xaml
的样式表,它具有所有初始样式,但随着时间变得如此混乱。现在我介绍第二风格称为Styles2.xaml
,我想从Styles.xaml
色彩元素移至Styles2.xaml
,并有Styles.xaml
参考来自Styles2.xaml
如何从另一个xaml样式表中引用xaml样式表
我有一个名为Styles.xaml
的样式表,它具有所有初始样式,但随着时间变得如此混乱。现在我介绍第二风格称为Styles2.xaml
,我想从Styles.xaml
色彩元素移至Styles2.xaml
,并有Styles.xaml
参考来自Styles2.xaml
如何从另一个xaml样式表中引用xaml样式表
你对它的引用添加使用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>
它工作。谢谢@Depechie – macgriffiths