1

I created a custom control in C# which has its template defined in Themes/Generic.xaml. The control (along with Themes/Generic.xaml) is defined in a project which outputs to a DLL. I'm not sure if this is important, but the control is in a subfolder.

When I reference the control from the main executable, OnApplyTemplate() in the control's C# is never called, and the control shows up with no style information applied.

This only happens in the release build; the debug build works fine.

If I redefine the template in the resources of the control hosting the control (e.g. Window.Resources) the control works fine. It seems that Visual Studio is not linking Themes/Generic.xaml to the control.

Ming Slogar
  • 2,327
  • 1
  • 19
  • 41
  • 1
    Most people that I have seen that give down votes, don't usually have the stones (or the knowledge) to back that down vote up. Ah, the joys of internet anonymity. – Brian Feb 23 '14 at 22:09
  • I have to agree with Brian. – f470071 Sep 21 '15 at 12:33

1 Answers1

0

It turns out that I had an empty "en-US" folder inside the release output folder, left over from a localization experiment. Apparently the WPF/.NET engine tried to load the control template from the "en-US" folder, and when it failed, did not revert back to the template defined in the assembly.

The solution was simple - delete the folder.

Ming Slogar
  • 2,327
  • 1
  • 19
  • 41