I have a WPF custom control MyControl.cs
in my application project (.exe) with its style in a resource dictionary in MyControlResources.xaml
. This xaml is specified in app.xaml
as a part of the merged dictionaries. Everything works fine.
Now I want to move this custom control into an existing DLL project that the application references. Is there a way that I can create the resource dictionary "assignment" in the DLL and make it transparent to the callers i.e. the application project can use it like any built-in control that doesn't require you to know anything about resource dictionary?
I've read about creating a new custom control project can do the trick, but it's only one control for which I don't want to create a new project for. Anyone knows how to do it in an existing class library DLL?
This answer helped me find the trick.
Create a file called Themes\Generic.xaml
to merge the resource dictionary.
Add the following attribute to Assembly.cs
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With