Beispiel #1
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="Common.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 async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            try
            {
                progressBar.Visibility = Visibility.Visible;
                pageTitle.Text         = "News about " + (string)e.NavigationParameter;
                teamName = (string)e.NavigationParameter;
                var sampleDataGroups = await GetNewsData.GetNewsFeeds((string)e.NavigationParameter);

                if (sampleDataGroups != null)
                {
                    progressBar.Visibility         = Visibility.Collapsed;
                    this.DefaultViewModel["Items"] = sampleDataGroups;
                }
                else
                {
                    progressBar.Visibility = Visibility.Collapsed;
                    generateErrorHandler("Well, this is embarrassing", "We happened to encounter a minor error while we were working. Apologies!");
                }
            }
            catch (Exception)
            {
                generateErrorHandler("Well, this is embarrassing", "We happened to encounter a minor error while we were working. Apologies!");
            }
        }
Beispiel #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="Common.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 async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            try
            {
                progressBar.Visibility = Visibility.Visible;
                string             navparam  = "" + e.NavigationParameter;
                string[]           rnavparam = navparam.Split('&');
                List <GetNewsData> videoData = new List <GetNewsData>();
                videoData = await GetNewsData.GetNewsFeeds(rnavparam[1].ToString());

                if (videoData != null)
                {
                    progressBar.Visibility = Visibility.Collapsed;
                    foreach (var newsObject in videoData)
                    {
                        if (newsObject.newsId == rnavparam[0].ToString())
                        {
                            pageTitle.Text          = "News about " + rnavparam[1];
                            newsDescription.Text    = newsObject.newsLeadParragraph + "\nNews source: " + newsObject.newsSource;
                            readNewsWeb.NavigateUri = newsObject.newsUrl;
                            newsTitle.Text          = "" + newsObject.newsHeadline;
                            newsImage.Source        = new BitmapImage(new Uri("" + newsObject.newsThumbnail320));
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    progressBar.Visibility = Visibility.Collapsed;
                    generateErrorHandler("Well, this is embarrassing", "We happened to encounter a minor error while we were working. Apologies!");
                }
            }
            catch (Exception)
            {
                generateErrorHandler("Well, this is embarrassing", "We happened to encounter a minor error while we were working. Apologies!");
            }
            // End of method
        }