public void ApplyStyleToVirtualElement(RadElement element) { if (!element.IsInValidState(false)) { return; } if (!element.PropagateStyleToChildren || element.IsThemeRefreshSuspended) { return; } if (this.state == StyleManagerState.Detaching || this.state == StyleManagerState.Detached) { return; } ComponentThemableElementTree oldTree = element.ElementTree; element.UpdateReferences(this.owner.ElementTree, false, true); this.MapStylesToElementsRecursive(element); bool parentNotPropagateStyleToChildren; StyleMap map = this.FindStyleMapForElement(element, out parentNotPropagateStyleToChildren); if (map != null) { if (this.styleElementMap.ContainsKey(element.GetHashCode())) { this.styleElementMap.Remove(element.GetHashCode()); } else { map.BuildStyle(); map.SetStyleSheet(element.ComposeStyle()); } map.OnElementRemoved(element); } element.UpdateReferences(oldTree, false, true); }