WPF Custom Controls Are Invisible
I suppose you have found a solution to your problem meanwhile.However, for the case, anyone else stumbles over the same problem as you did:The probably only explanation why a custom control does not show up although all the steps for creating it have been done correctly, as you did, is a missing entry in the AssemblyInfo.cs.This file must contain the following entry:
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly))]
Without this entry, the generic.xaml-file is ignored and therefore the default-control-template is not found, so the control will not get a control-template at all and therefore will not show up. This explains, too, why your control suddenly did show up when you disabled its static constructor. The line:
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomButton), new FrameworkPropertyMetadata(typeof(CustomButton)));
tells the control to use its own default-style instead of inheriting it from its base-class. So without this line the CustomButton will simply reuse the default control-template of the Button-class, with the consequence, that nothing you write into the generic.xaml will take any effect for the CustomButton.
Where is your custom control template?
By saying
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomButton), new FrameworkPropertyMetadata(typeof(CustomButton)));
you're indicating you want to defined your own custom control. I think if you remove that, you'll see your button.