JiBéDoublevé
JiBéDoublevé

Reputation: 4269

WPF: OnApplyTemplate is not called anymore when I moved code into another DLL

Let's try to explain it clearly.

I've got a custom control built as a WPF application and it works fine. I've moved all the code into a external DLL. After this change, when I load the application, the method OnApplyTemplate() is not called any more and the control is not rendered either

Do you have any idea about the solution?

Thanks in advance...

Upvotes: 4

Views: 2504

Answers (2)

Chris
Chris

Reputation: 106

The main difference between a standard Wpf Applicaton and a WPF Custom Control library are the following lines of code.

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, 
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, 
// app, or any theme specific resource dictionaries)
)]

Adding these lines of code to your Assembly should fix your bug.

Upvotes: 9

JiBéDoublevé
JiBéDoublevé

Reputation: 4269

Thanks to dowhilefor, I've found the solution!

I've recreated a new library as a WPF Custom Control Library and it works.

It is a little overkill to recreate a new project so if someone can explain to me how to reconfigure an existing project, it'd be very nice ;)

Upvotes: 3

Related Questions