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