Exemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs args)
        {
            // Navigating from MainPage
            if (this.NavigationContext.QueryString.ContainsKey("ComposerInfoIndex"))
            {
                composerInfoIndex = Int32.Parse(this.NavigationContext.QueryString["ComposerInfoIndex"]);
                albumInfoIndex    = Int32.Parse(this.NavigationContext.QueryString["AlbumInfoIndex"]);
            }

            // Reactivating from tombstoning
            else if (PhoneApplicationService.Current.State.ContainsKey("ComposerInfoIndex"))
            {
                composerInfoIndex = (int)PhoneApplicationService.Current.State["ComposerInfoIndex"];
                albumInfoIndex    = (int)PhoneApplicationService.Current.State["AlbumInfoIndex"];
            }

            ComposerInfo composerInfo = MusicPresenter.Current.Composers[composerInfoIndex];
            AlbumInfo    albumInfo    = composerInfo.Albums[albumInfoIndex];

            // Set page title and DataContext
            PageTitle.Text   = composerInfo.Composer;
            this.DataContext = albumInfo;

            // Get the media state when it changes and also right now
            MediaPlayer.MediaStateChanged += OnMediaPlayerMediaStateChanged;
            OnMediaPlayerMediaStateChanged(null, EventArgs.Empty);

            base.OnNavigatedTo(args);
        }
Exemplo n.º 2
0
        void OnListBoxSelectionChanged(object sender, SelectionChangedEventArgs args)
        {
            ComposerInfo composerInfo      = pivot.SelectedItem as ComposerInfo;
            int          composerInfoIndex = MusicPresenter.Current.Composers.IndexOf(composerInfo);

            AlbumInfo albumInfo      = (sender as ListBox).SelectedItem as AlbumInfo;
            int       albumInfoIndex = composerInfo.Albums.IndexOf(albumInfo);

            // Construct URI with two indices and navigate
            string destinationUri =
                String.Format("/AlbumPage.xaml?ComposerInfoIndex={0}&AlbumInfoIndex={1}",
                              composerInfoIndex, albumInfoIndex);

            this.NavigationService.Navigate(new Uri(destinationUri, UriKind.Relative));
        }