Silverlight MergedDictionary - Attribute Value out of Range

Posted by Wonko the Sane on Stack Overflow See other posts from Stack Overflow or by Wonko the Sane
Published on 2010-04-27T21:19:25Z Indexed on 2010/04/27 21:23 UTC
Read the original article Hit count: 892

Hello All,

I have a Silverlight-3 solution that contains a few different projects. I want to have one "common" project for holding controls and resources that will be used by multiple other projects.

Within the common project, there is a folder called Resources, which holds a ResourceDictionary (CommonColors.xaml). This is set to be built as a Resource, Do Not Copy.

I add a reference to the common project in another project (call it UncommonControls), and attempt to add the ResourceDictionary as a MergedDictionary:

<UserControl.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/Common;component/Resources/CommonColors.xaml" />
            <ResourceDictionary Source="/UncommonControls;component/Resources/UncommonStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</UserControl.Resources>

When I try to run, I get an exception:

Attribute /Common;component/Resources/CommonColors.xaml value is out of range. [Line: 14 Position: 44] --- Inner Exception --- The given key was not present in the dictionary.

However, if I reference a ResourceDictionary local to Uncommon (such as the UncommonStyles.xaml, above) project, which is set up with the same Build properties, it works fine.

I haven't seen anything that says SL3 can't reference an external ResourceDictionary (on the contrary, I've seen an example of using one, albeit with no downloadable project to verify the behavior).

Thanks, Wonko

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about silverlight-3.0