protected override void OnTemplateChanged(DataTemplate oldTemplate, DataTemplate newTemplate) { base.OnTemplateChanged(oldTemplate, newTemplate); if (oldTemplate != null) { RibbonHelper.ClearPseudoInheritedProperties(_templateRoot); if (_templateRoot != null) { // Clearing the Ribbon property value which was set earlier. _templateRoot.ClearValue(RibbonControlService.RibbonPropertyKey); } _templateRoot = null; } }