I have several several styles and templates for both standard WPF controls and custom controls in an external custom control libary project. For each control, there's a ResourceDictionary
in my \Themes
folder, along with a Generic.xaml
which contains a merged dictionary of all the other XAML files.
I made sure that:
- The
Generic.xaml
is in theThemes\
folder within the root of my project - The
Generic.xaml
has a Build Action ofPage
. - The
Generic.xaml
uses the custom tool flagMSBuild:Compile
. - The external library has the following line declared:
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
What I tried:
Sources
Source="MyControl.xaml"
Source="/MyLibrary;component/Themes/MyControl.xaml"
Source="/MyLibrary;component/Themes/MyControl.xaml"
Source="/pack://application:,,,/Themes/MyControl.xaml"
Source="/pack://application:,,,/MyLibrary;component/Themes/MyControl.xaml"
Application
- Manually referencing the
Generic.xaml
in my application with all possible source declarations
However, nothing works. The application stays completely unthemed, even though I can see that all dictionaries have been loaded when accessing Application.Current.Resources
.
It's also worth noting that most of my control themes contain additional dynamic resources (for colors etc.), which are loaded manually when the application starts.
It seems that I'm facing the exact same unanswered problem as the OP in this question here, however they state that manually referencing the Generic.xaml
works for them.