I am looking for a way to share ResourceDictionary
between projects.
Adding new item to shared project doesn't offer resource dictionary. It can be created in other (main) project and dragged. But then I can't change its build options to Page:
The idea is to load resource dictionary like this
var dictionary = new ResourceDictionary();
dictionary.Source = new Uri("/WpfApplication91;component/Dictionary2.xaml", UriKind.Relative);
This is obviously fails currently with
An exception of type 'System.IO.IOException' occurred in PresentationFramework.dll but was not handled in user code
Additional information: Cannot locate resource 'dictionary2.xaml'.
Any ideas?
It's possible to manually edit shared project to set build action for resource dictionary.
Shared project consists of
Project.shproj
andProject.projitems
files, open second and locate dictionary there:Add after that
it's a copy/paste thing from normal
csproj
for WPF project containing dictionary.Seems to work, though this build action is not visible when project is loaded into Visual Studio. Adding files to shared project doesn't affect this manual change.
Now I can have shared project containing resource dictionary, yay!
Resource dictionary can be merged into application dictionaries like if it's located in the root of the project (to use as static/dynamic resource in xaml designer):
and/or loaded manually, e.g. using this pack Uri :