Automatic (keyless) styles not applied when in a MergedDictionaries in another assembly

Posted by Catalin DICU on Stack Overflow See other posts from Stack Overflow or by Catalin DICU
Published on 2010-04-19T10:08:30Z Indexed on 2010/04/19 10:13 UTC
Read the original article Hit count: 532

Filed under:
|

I moved the styles and templates xaml files form my application (.exe) project to a library project (.dll) because I want to use them in multiple applications.

In App.xaml I have:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MyApplication.Common;component/Resources/All.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

In All.xaml (in the Common assembly) :

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Styles.xaml" />
    <ResourceDictionary Source="Templates.xaml" />
    <ResourceDictionary Source="Converters.xaml" />
</ResourceDictionary.MergedDictionaries>

With this code keyless styles in Styles.xaml aren't applied.

Instead, if I reference them directly in App.xaml, it works :

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MyApplication.Common;component/Resources/Styles.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MyApplication.Common;component/Resources/Templates.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MyApplication.Common;component/Resources/Converters.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Can anyone explain why it happens ?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about .NET