static UserControl() { // UseContentTemplate ControlTemplate template = new ControlTemplate(); template.SetMethodToInstantiateFrameworkTemplate((owner) => { TemplateInstance instance = new TemplateInstance(); instance.TemplateOwner = owner; instance.TemplateContent = ((UserControl)owner).Content as FrameworkElement; return(instance); }); template.Seal(); UseContentTemplate = template; }