I am building a WPF desktop app with .net framework 4.7.2. and need some help for merging resource dictionaries.
I have 1 solution with 2 projects:
Inside the parent project I have created a ResourceDictionary.xaml with some colors etc. and I want to be able to propagade that dictionary to the child project so it can be used if I run the child project separately from the parent (testing, designing etc.)
I have tried putting this inside the child but it does not work:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://ProcesingDesktopHub:,,,/ProcResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
I hope I described my question correctly.
A solution cannot have circular references between projects.
Since the parent project refers to the child, then, accordingly, the child cannot refer to the parent in any way.
One of the solutions: move the shared resources (if you need not only resources, but also types, controls, etc.) to a third project that will be referenced by the parent and child projects.
Second variant: if you do not provide for the use of the child project outside the parent project, then you can use the design-time resource creation technique described here: https://stackoverflow.com/a/17712041/13349759
And in runtime, the resources of the parent project will be used.
Design time sounds good but I would need to run the parent project for debugging purposes each time if I understood it correctly.
If you want to separately debug a child project, then creating a third project with shared resources will be the best varaint. In addition, if you ALWAYS use the parent project only together with the child, then pay attention to the answer from @MuhammadSulaiman.