/// <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);

                PicturesCategoryModel model = ((App)Application.Current).PicturesModel;

                // set model for selected image as a data context for page
                DataContext = model.GetModelForItem(selIndex);
            }
        }
Exemple #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);
        }