Search code examples
c#wpfuser-controlsglobalresourcedictionary

Using a global ResourceDictionary in a UserControl Library


I have have "Project A" with "MyResourceDictionary.xaml" in "App.xaml"

<Application.Resources>

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="MyResourceDictionary.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

</Application.Resources>

I want to also use "MyResourceDictionary.xaml" in my user control library - "Project B"

Can I do this?

Thanks, Eamonn


Solution

  • Check out the pack URI syntax. Something like:

    <ResourceDictionary Source="ProjectB;component/MyResourceDictionary"/>