I’m trying to get my application (WPF) use a referenced assembly in my App.xaml using Pack URIs. In my solution I have several projects. In the base application, I just have my App.xaml. I would like this to use a referenced assembly.
Call my base project with App.xaml Project 1 (in the solution). This is the relevant part of App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MyProject.Project2;component/Themes/Generic.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Project 2 has a folder “Themes” with Generic.xaml. I’m fairly sure that I’m doing the Pack URI incorrectly because none of the styling in Generic.xaml is being used (I’m overriding the default window with a custom window, but it does not currently work. Application shows up with default window styling, everything inside the window is black).
Folder hierarchy:
MainFolder
Project 1
App.xaml
bin
Debug
Application.exe
Project 2
Themes
Generic.xaml
Questions:
- Can someone explain the
pack://application:,,,syntax? What does all of this mean? - What am I doing wrong with the Pack URI?
Thanks in advance.
Figured it out. Turns out in MyProject.Project2 I needed the following code in AssemblyInfo.cs: