OnApplyTemplate API not getting invoked when custom control moved to class library

35 views Asked by At

I have created a sample custom control using WPF custom control project. Added Styles in the Generic.xaml file and all seem to be working fine when it was within the project. In the actual implementation I had to move this implementation to a class library which has the user controls that consume this custom control. When i moved the control i had done all the necessary items. I created Themes folder, added generic.xaml file, made sure the custom control has static constructor, made sure that Themeinfo is added to assemblyinfo.cs. However the styles are not getting invoked and OnApplyTemplate API is not called at all. I tried to keep it in a separate assembly, add that as a reference and yet it didn't work. I am running out of choice here and I got stuck. Can someone help me with the issue please. Please suggest anything i could try.

I created Themes folder, added generic.xaml file, made sure the custom control has static constructor, made sure that Themeinfo is added to assemblyinfo.cs.

[TemplatePart(Name="PART_TwoThumbContainer", Type=typeof(StackPanel))]
[TemplatePart(Name = "PART_BlackThumb", Type = typeof(Thumb))]
public class CustThumb : Control
{
  static CustThumb()
  {
     DefaultStyleKeyProperty.OverrideMetadata(typeof(CustThumb), new FrameworkPropertyMetadata(typeof(CustThumb)));
  }
  public override void OnApplyTemplate()
  {
  }
}
0

There are 0 answers