public void RestoreState(AppState state, SongTextControl songTextControl, ListBox listArtistsControl) { listArtistsControl.Visibility = state.ListArtistsControlVisible; songTextControl.Visibility = state.SongTextControlVisible; songTextControl.SetStackPanel(state.SongTextControlStack); ((ObservableCollection<MusicItem>)listArtistsControl.ItemsSource).Clear(); foreach (MusicItem item in state.ListArtistsControlItems) { ((ObservableCollection<MusicItem>)listArtistsControl.ItemsSource).Add(item); } }
public void SaveState(SongTextControl songTextControl, ListBox listArtistsControl) { var state = new AppState { ListArtistsControlItems = new ObservableCollection<MusicItem>(), }; state.ListArtistsControlVisible = listArtistsControl.Visibility; state.SongTextControlVisible = songTextControl.Visibility; state.SongTextControlStack = songTextControl.GetStackPanel(); foreach (MusicItem item in (ObservableCollection<MusicItem>)listArtistsControl.ItemsSource) { state.ListArtistsControlItems.Add(item); } }