private async void itemGridView_ItemClick(object sender, ItemClickEventArgs e) { // Click the RiddleItem will open web browser to show the web content // Get the link first RiddleItem riddle = e.ClickedItem as RiddleItem; if (riddle == null) { return; } // The URI to launch string uriToLaunch = riddle.Link; // Create a Uri object from a URI string var uri = new Uri(uriToLaunch); // Launch the URI await Windows.System.Launcher.LaunchUriAsync(uri); }
public static async Task<List<RiddleItem>> GetFeedAsync() { string feedUriString = RiddleRSS; Windows.Web.Syndication.SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(feedUriString); try { SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); // This code is executed after RetrieveFeedAsync returns the SyndicationFeed. // Process the feed and copy the data you want into the FeedData and FeedItem classes. //FeedData feedData = new FeedData(); List<RiddleItem> riddles = new List<RiddleItem>(); //if (feed.Title != null && feed.Title.Text != null) //{ // feedData.Title = feed.Title.Text; //} //if (feed.Subtitle != null && feed.Subtitle.Text != null) //{ // feedData.Description = feed.Subtitle.Text; //} if (feed.Items != null && feed.Items.Count > 0) { // Use the date of the latest post as the last updated date. //feedData.PubDate = feed.Items[0].PublishedDate.DateTime; foreach (SyndicationItem item in feed.Items) { RiddleItem feedItem = new RiddleItem(); if (item.Title != null && item.Title.Text != null) { feedItem.Title = item.Title.Text; } if (item.PublishedDate != null) { feedItem.PubDate = item.PublishedDate.DateTime.ToString(); } if (item.Authors != null && item.Authors.Count > 0) { feedItem.Category = item.Categories[0].Label.ToString(); } // Handle the differences between RSS and Atom feeds. if (feed.SourceFormat == SyndicationFormat.Atom10) { //if (item.Content != null && item.Content.Text != null) //{ // feedItem.Content = item.Content.Text; //} if (item.Id != null) { feedItem.Link = new Uri(item.Id).ToString(); } } else if (feed.SourceFormat == SyndicationFormat.Rss20) { //if (item.Summary != null && item.Summary.Text != null) //{ // feedItem.Content = item.Summary.Text; //} if (item.Links != null && item.Links.Count > 0) { feedItem.Link = item.Links[0].Uri.ToString(); } } riddles.Add(feedItem); } } return riddles; } catch (Exception ex) { Debug.WriteLine(ex.Message); return null; } }
public static async Task <List <RiddleItem> > GetFeedAsync() { string feedUriString = RiddleRSS; Windows.Web.Syndication.SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(feedUriString); try { SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); // This code is executed after RetrieveFeedAsync returns the SyndicationFeed. // Process the feed and copy the data you want into the FeedData and FeedItem classes. //FeedData feedData = new FeedData(); List <RiddleItem> riddles = new List <RiddleItem>(); //if (feed.Title != null && feed.Title.Text != null) //{ // feedData.Title = feed.Title.Text; //} //if (feed.Subtitle != null && feed.Subtitle.Text != null) //{ // feedData.Description = feed.Subtitle.Text; //} if (feed.Items != null && feed.Items.Count > 0) { // Use the date of the latest post as the last updated date. //feedData.PubDate = feed.Items[0].PublishedDate.DateTime; foreach (SyndicationItem item in feed.Items) { RiddleItem feedItem = new RiddleItem(); if (item.Title != null && item.Title.Text != null) { feedItem.Title = item.Title.Text; } if (item.PublishedDate != null) { feedItem.PubDate = item.PublishedDate.DateTime.ToString(); } if (item.Authors != null && item.Authors.Count > 0) { feedItem.Category = item.Categories[0].Label.ToString(); } // Handle the differences between RSS and Atom feeds. if (feed.SourceFormat == SyndicationFormat.Atom10) { //if (item.Content != null && item.Content.Text != null) //{ // feedItem.Content = item.Content.Text; //} if (item.Id != null) { feedItem.Link = new Uri(item.Id).ToString(); } } else if (feed.SourceFormat == SyndicationFormat.Rss20) { //if (item.Summary != null && item.Summary.Text != null) //{ // feedItem.Content = item.Summary.Text; //} if (item.Links != null && item.Links.Count > 0) { feedItem.Link = item.Links[0].Uri.ToString(); } } riddles.Add(feedItem); } } return(riddles); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(null); } }