WPF 4: MergedDictionaries don't seem to work any more
I have the below block of XAML
'BaseStyles.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ShinyBlue.xaml"/>
<ResourceDictionary Source="DataGrid.Generic.xaml"/>开发者_如何学Go;
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Forms that reference this work in design-time, but not in run time. If my form references ShinyBlue.xaml or DataGrid.Generic.xaml directly, that style sheet works.
EDIT
If I paste this directly into the form, it works correctly. Appearently the problem somehow has to do with my wrapper.
Broken
<Window.Resources>
<ResourceDictionary Source="../BaseStyles.xaml"/>
</Window.Resources>
Works
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ShinyBlue.xaml"/>
<ResourceDictionary Source="DataGrid.Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
Try including your whole path from namespace to filename:
<ResourceDictionary Source="pack://application:,,,/[YourDll];component/[YourLocation]/ShinyBlue.xaml"/>
Where [YourDll] is the name of your project, and [YourLocation] is the location where the ResourceDictionary resides in your dll.
精彩评论