tags:

views:

38

answers:

1

Resource dictionary

03-11-2010 10:56 AM |

I have two different projects. I linked a resource directory in using add existing item add as link.

Silverlight does not see the resource dictionary when it is a linked file and give me an out of range error.

Any work around to this or any better way to use the same file across two projects?

A: 

I would reference the assembly that has the resource dictionary normally (don't add it in as a link), and then bring it into the application using Merged Dictionaries. You can specify a resource dictionary in an external assembly to merge into the current application or page's resource dictionaries.

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/SharedThemeAssembly;component/MyStyles.xaml"/>
            ...other ResourceDictionaries to merge in...
        </ResourceDictionary.MergedDictionaries>
     </ResourceDictionary>
</Application.Resources>

I answered a similar SO question here: http://stackoverflow.com/questions/2268658/silverlight-multiple-project-sharing-the-same-style-files/2268927#2268927

Dan Auclair