Reputation: 620
Is there a way to use a resource dictionary in multiple applications? What I have is a theme generator which uses merged dictionaries etc... works GREAT! I'm looking for a way to reference this project for the resource dictionaries into all my applications. (thus, having my theme engine in every File>New I decide to create) So far my research has led me to nothing.
Upvotes: 1
Views: 103
Reputation: 620
Ok so I've found out that I can use the pack URI syntax to grab the resource dictionaries from application A and use them in application B
First I made a classlibrary and removed the default class1.cs Then I added a new item (there was no option for a .xaml file so I added a .xml file and changed the extension) Then moved the resource dictionary code into that file. Referenced the new .dll as you would any other and now I can access the resource dictionary file using the below syntax.
<ResourceDictionary Source = "pack://application:,,,/App_A;Component/App_A_ResourceDictionary.xaml"/>
When swapping the files its the same syntax only omit the "pack://application,,," part. Although this wasn't everything I wanted (so far) it has been the best solution I've found.
The part now that I want is the ability to house the swapping logic within the .dll. If I can do that... then my theme library can be PnP to any app with minimum fuss.
Upvotes: 1