[SOLVED] Reference external ResourceDictionary

User avatar
TooTallTommyT
Posts: 15
Joined: Tue Aug 21, 2018 6:51 am
Location: Las Vegas, NV

[SOLVED] Reference external ResourceDictionary

Postby TooTallTommyT » Tue Aug 28, 2018 7:49 am

I have a ResourceDictionary that I've moved to an external assembly, so that I can use it across all my apps, but I cannot seem to find the right approach to make it visible/usable in my projects. I've tried a variety of methods of setting Source attribute to no avail. Any suggestions?
It ain't easy being green!

JS-Support @Userware
Site Admin
Posts: 912
Joined: Tue Apr 08, 2014 3:42 pm

Re: Reference external ResourceDictionary

Postby JS-Support @Userware » Wed Aug 29, 2018 2:50 am

Hi,

You need to add a reference to it using the "MergedDictionaries" syntax. For example, you can reference it in the "App.xaml" file of your startup project so that it becomes visible application-wide. To do so, please use the following example:

Code: Select all

<Application
    x:Class="MyApplication1.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MyResourceDictionary1.xaml"/>
                <ResourceDictionary Source="Themes/Generic.xaml"/>
                <ResourceDictionary Source="ASSEMBLYNAME;component/FOLDERNAME/FILENAME.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>


(you need to replace "ASSEMBLYNAME", "FOLDERNAME", and "FILENAME" with the actual values)

Regards,
JS-Support

User avatar
TooTallTommyT
Posts: 15
Joined: Tue Aug 21, 2018 6:51 am
Location: Las Vegas, NV

Re: Reference external ResourceDictionary

Postby TooTallTommyT » Wed Aug 29, 2018 11:29 am

That mostly did the trick.... I did have to add forward slash ( / ) preceding the assemblyname, but once done, it worked perfectly!
Thanks!

<ResourceDictionary Source=ASSEMBLYNAME;component/FOLDERNAME/FILENAME.xaml/>

to:

<ResourceDictionary Source=/ASSEMBLYNAME;component/FOLDERNAME/FILENAME.xaml/>
It ain't easy being green!

TaterJuice
Posts: 109
Joined: Thu Mar 16, 2017 5:40 am
Contact:

Re: Reference external ResourceDictionary

Postby TaterJuice » Thu Aug 30, 2018 6:41 am

TooTallTommyT wrote:That mostly did the trick.... I did have to add forward slash ( / ) preceding the assemblyname, but once done, it worked perfectly!
Thanks!

<ResourceDictionary Source=ASSEMBLYNAME;component/FOLDERNAME/FILENAME.xaml/>

to:

<ResourceDictionary Source=/ASSEMBLYNAME;component/FOLDERNAME/FILENAME.xaml/>


Thanks for sharing your solution with the community, Tommy!


Return to “General Discussion and Other”

Who is online

Users browsing this forum: No registered users and 3 guests

 

 

cron