/// <summary>
        /// From PhoneApplicationPage.
        /// Called when a page becomes the active page in a frame.
        /// </summary>
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            string selectedIndex;

            // check if navigation context contains selectedItem query string, if so get the value to obtain selected item index
            if (NavigationContext.QueryString.TryGetValue("SelectedItem", out selectedIndex))
            {
                int selIndex = int.Parse(selectedIndex);

                MusicCategoryModel model = ((App)Application.Current).MusicModel;

                // set data context for the page
                DataContext = model.GetModelForIndex(selIndex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads data for both, music and pictues models
        /// </summary>
        private void LoadDataForModels()
        {
            MediaLibrary library = new MediaLibrary();

            List <Song> songs = new List <Song>();

            foreach (var song in library.Songs)
            {
                songs.Add(song);
            }

            MusicModel = new MusicCategoryModel("Music", songs);

            List <Picture> pictures = new List <Picture>();

            foreach (var picture in library.Pictures)
            {
                pictures.Add(picture);
            }

            PicturesModel = new PicturesCategoryModel("Pictures", pictures);
        }