我已成功将一个资源字典(包含我的主题/样式模板资源集合)添加到我的Window.Resources。这会适当地调整每个窗口的样式。但是,当我添加相同的行时:
<ResourceDictionary Source="BureauBlack.xaml" x:Key="BureauBlackKey"/>
到我的App.xaml没有任何变化。
编辑#1:
<Application x:Class="EventPlanner.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:EventPlanner.ViewModels"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<vm:ViewModelLocator x:Key="ViewModelLocatorKey"/>
<ResourceDictionary Source="BureauBlack.xaml" x:Key="BureauBlackKey"/>
</ResourceDictionary>
</Application.Resources>
</Application>
答案 0 :(得分:4)
您需要将主题资源字典添加到MergedDictionaries
集合:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="BureauBlack.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- other resources go here -->
<vm:ViewModelLocator x:Key="ViewModelLocatorKey"/>
</ResourceDictionary>
</Application.Resources>