I have a Custom Control which uses some PART controls:
[TemplatePart(Name = \"PART_TitleTextBox\", Type = typeof(TextBox))]
[TemplatePart(Name = \"PART_Titl
I am going to add my own answer because both the above answers are incomplete as I have been struggling with this problem for some time now.
As said by MoMo and Kai G above:
A. The controls template and styles should be located in the Generic.xaml file a folder called Themes of the root of your project.
B. Make sure your namespaces are correct in the Generic.xaml
C. Set the style key in the constructor of your control.
D. Ensure the theme attribute is in the assemblyinfo.cs file
BUT you also need to ensure that your Generic.xaml file is set for the Build Action as Page:Do Not copy.
If you fail to do this or the value was somehow set to something other than this, the OnApplyTemplate()
method will not be invoked.