5

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?

NS.X.
  • 2,072
  • 5
  • 28
  • 55

1 Answers1

2

This answer helped me find the trick.

  1. Create a file called Themes\Generic.xaml to merge the resource dictionary.

  2. Add the following attribute to Assembly.cs

    [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

Community
  • 1
  • 1
NS.X.
  • 2,072
  • 5
  • 28
  • 55