/// <include file='doc\StyleSheet.uex' path='docs/doc[@for="StyleSheet.SaveViewState"]/*' /> protected override Object SaveViewState() { Object baseState = base.SaveViewState(); int styleCount = _styles.Count; Object[] stylesState = new Object[styleCount]; if (_saveAll) { for (int i = 0; i < styleCount; i++) { Style style = (Style)_styles.GetAt(i); style.SetDirty(); stylesState[i] = ((IStateManager)style).SaveViewState(); } } else { bool anySaved = false; for (int i = 0; i < styleCount; i++) { Style style = (Style)_styles.GetAt(i); stylesState[i] = ((IStateManager)style).SaveViewState(); if (stylesState[i] != null) { anySaved = true; } } if (!anySaved) { stylesState = null; } } if (stylesState != null || baseState != null) { return(new Object[] { baseState, _saveAll, stylesState }); } else { return(null); } }