public override void OnSetParent() { base.OnSetParent(); // This is not a MobilePage or the styleSheet is already the active styleSheet. // The latter happens when the active StyleSheet is drag/drop to another location // which forces its parent to be changed. if (MobilePage == null) { return; } if (MobilePage.StyleSheet == _styleSheet) { if (!(_styleSheet.Parent is MobilePage || _styleSheet.Parent is MobileUserControl)) { UpdateActiveStyleSheet(); } return; } if (MobilePage.StyleSheet != StyleSheet.Default) { // can't accept more than 1 stylesheet TreatAsDuplicate(true); // the current valid StyleSheet is intentionaly refreshed because // if this stylesheet instance is recreated via a Undo operation // the current valid StyleSheet appears as a duplicate if not refreshed. IDesigner designer = Host.GetDesigner((IComponent)MobilePage.StyleSheet); Debug.Assert(designer != null, "designer is null in StyleSheetDesigner"); StyleSheetDesigner ssd = (StyleSheetDesigner)designer; ssd.UpdateRendering(); } else if (_styleSheet.Parent is MobilePage || _styleSheet.Parent is MobileUserControl) { // the active stylesheet is changed MobilePage.StyleSheet = _styleSheet; _isDuplicate = false; } RefreshPageView(); }