private void OnArtistPanoramaViewLoaded(object sender, RoutedEventArgs e) { // the page is an humble object, and the navigatorService, its sole dependency. var navigator = IoC.Container.Get <INavigatorService>(); navigator.ActivateNavigationService(NavigationService, true); if (DataContext == null) { var artistTicket = NavigationContext.QueryString["artistTicket"]; var artistAlbumsTicket = NavigationContext.QueryString["albumsListTicket"]; if (_newPageInstance && State.ContainsKey(ArtistPanoramaViewCurrentArtist)) { _artist = (SynoItem)this.State[ArtistPanoramaViewCurrentArtist]; } else { _artist = (SynoItem)navigator.UrlParameterToObjectsPlateHeater.GetObjectForTicket(artistTicket); } IEnumerable <SynoItem> artistItems = null; IEnumerable <AlbumViewModel> albumViewModels; if (_newPageInstance && State.ContainsKey(ArtistPanoramaViewItems)) { throw new NotImplementedException("deal with the viewmodels not with the synoitems anymore here"); artistItems = (IEnumerable <SynoItem>) this.State[ArtistPanoramaViewItems]; //artistPanoramaViewModel.BuildArtistItems(_artistItems); } else { //artistPanoramaViewModel.QueryAndBuildArtistItems(); albumViewModels = (IEnumerable <AlbumViewModel>)navigator.UrlParameterToObjectsPlateHeater.GetObjectForTicket(artistAlbumsTicket); } var albumTicket = NavigationContext.QueryString["albumTicket"]; int artistPanoramaViewActivePanelIndex = 0; if (_newPageInstance && State.ContainsKey(ArtistPanoramaViewCurrentArtist)) { artistPanoramaViewActivePanelIndex = (int)this.State[ArtistPanoramaViewActivePanelIndex]; } else { var album = (AlbumViewModel)navigator.UrlParameterToObjectsPlateHeater.GetObjectForTicket(albumTicket); artistPanoramaViewActivePanelIndex = albumViewModels.ToList().IndexOf(album); } ArtistPanoramaViewModel artistPanoramaViewModel = IoC.Container.Get <ArtistPanoramaViewModelFactory>().Create(this._artist, albumViewModels, artistPanoramaViewActivePanelIndex); DataContext = artistPanoramaViewModel; } }
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { ArtistPanoramaViewModel artistPanoramaViewModel = this.DataContext as ArtistPanoramaViewModel; if (artistPanoramaViewModel != null) { State[ArtistPanoramaViewCurrentArtist] = _artist; State[ArtistPanoramaViewItems] = _artistItems; State[ArtistPanoramaViewActivePanelIndex] = artistPanoramaViewModel.CurrentArtistItemIndex; } base.OnNavigatedFrom(e); }
//public ArtistPanoramaViewModel Create(SynoItem artist, IEnumerable<SynoItem> artistItems) //{ // ArtistPanoramaViewModel artistPanoramaViewModel = new ArtistPanoramaViewModel(this._searchService, this._eventAggregator, this._pageSwitchingService, artist, this._notificationService); // artistPanoramaViewModel.BuildArtistItems(artistItems); // return artistPanoramaViewModel; //} public ArtistPanoramaViewModel Create(SynoItem artist, IEnumerable <AlbumViewModel> albumViewModels, int artistPanoramaViewActivePanelIndex) { var artistPanoramaViewModel = new ArtistPanoramaViewModel(artist, albumViewModels, artistPanoramaViewActivePanelIndex, this._searchService, this._eventAggregator, this._pageSwitchingService, this._notificationService); return(artistPanoramaViewModel); }