WPF 4: MergedDictionaries no longer work

I have the following XAML block

'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"/>
    </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

Forms that reference this work at design time, but not at run time. If my form directly refers to the ShinyBlue.xaml or DataGrid.Generic.xaml file, this stylesheet works.

EDIT

If I paste this directly into the form, it works correctly. Apparently the problem has something to do with my wrapper.

Broken

<Window.Resources>
    <ResourceDictionary Source="../BaseStyles.xaml"/>
</Window.Resources>

Job

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="ShinyBlue.xaml"/>
    <ResourceDictionary Source="DataGrid.Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
+3
source share
1 answer

Try including the entire path from the namespace to the file name:

<ResourceDictionary Source="pack://application:,,,/[YourDll];component/[YourLocation]/ShinyBlue.xaml"/>

Where [YourDll] is the name of your project, and [YourLocation] is the place where the ResourceDictionary is in your DLL.

+2
source

Source: https://habr.com/ru/post/1741830/


All Articles