Ejemplo n.º 1
0
        private void songView_ItemClick(object sender, ItemClickEventArgs e)
        {
            KeyValuePair <Album, int> kvp;

            if (e.ClickedItem is AlbumItemControl)
            {
                kvp = new KeyValuePair <Album, int>(_currentAlbum, 0);
            }
            else
            {
                SongItemControl control = (SongItemControl)e.ClickedItem;
                kvp = new KeyValuePair <Album, int>(_currentAlbum,
                                                    MusicLibrary.Instance.GetSongs(_currentAlbum).IndexOf(((Song)control.DataContext)));
            }

            SwitchToNowPlayingView(kvp);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            if (commandBar.Visibility != Windows.UI.Xaml.Visibility.Visible)
            {
                commandBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }

            _currentAlbum = (Album)e.NavigationParameter;

            this.DefaultViewModel["Artist"] = MusicLibrary.Instance.GetArtist(_currentAlbum);
            this.DefaultViewModel["Album"]  = _currentAlbum;

            AlbumItemControl albumControl = new AlbumItemControl(_currentAlbum);

            songView.Items.Add(albumControl);
            foreach (Song song in MusicLibrary.Instance.GetSongs(_currentAlbum))
            {
                SongItemControl control = new SongItemControl();
                control.DataContext = song;
                control.SetValue(FlyoutBase.AttachedFlyoutProperty, this.Resources["AddToNowPlayingFlyout"]);
                control.Holding += SongItemControl_Holding;
                songView.Items.Add(control);
            }
        }
        private void SongItemControl_Loaded(object sender, RoutedEventArgs e)
        {
            SongItemControl control = (SongItemControl)sender;

            _controls.Add(control);
        }