开发者

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

  • I've try with Generic.xaml file is into a Themes directory (with capital T) in the root of the DLL which has the control and/or a Themes directory into the StartUp project.
  • If this info is important here's where I've found the control: http://www.codeproject.com/KB/WPF/WPFOutlookCalendar.aspx
  • The settings of the pro开发者_开发百科ject is
    • Output type: Class Library
    • Target framework: .Net Framework 4
  • I've create a simple DLL project and I've added the references manually

Do you have any idea about the solution?

Thanks in advance...


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.


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 ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜