开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜