async private Task parameterSet(string turi) { textBlockTargetFeed.Text = turi.ToString(); try { SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(turi); feed = await client.RetrieveFeedAsync(feedUri); FeedLsvModel feedData = new FeedLsvModel(); foreach (SyndicationItem item in feed.Items) { FeedItem feedItem = new FeedItem(); feedItem.Title = item.Title.Text; feedItem.PubDate = item.PublishedDate.DateTime; feedItem.Author = item.Authors[0].Name; // Handle the differences between RSS and Atom feeds. if (feed.SourceFormat == SyndicationFormat.Atom10) { feedItem.Content = item.Content.Text; feedItem.Link = new Uri(turi + item.Id); } else if (feed.SourceFormat == SyndicationFormat.Rss20) { feedItem.Content = item.Summary.Text; feedItem.Link = item.Links[0].Uri; } feedData.Items.Add(feedItem); } ItemListView.DataContext = feedData.Items; ItemListView.SelectedIndex = 0; } catch (Exception ex) { textBlockTargetFeed.Text = "ネットワークに問題が発生しました。RSSフィードが受信できません。 e:" + ex.ToString(); } }
async private void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if ((ItemListView.DataContext == null) || (ItemListView.SelectedIndex < 0)) { /* * feed変更時は前回のアイテムを吐き出す為に, * return,2回目で読む, * ItemListView.DataContext と * ItemListView.SelectedIndex 両方の判定が必要 */ return; } FeedItem f = new FeedItem(); var item = feed.Items[ItemListView.SelectedIndex]; string link = string.Empty; if (item.Links.Count > 0) { link = item.Links[0].Uri.AbsoluteUri; currentViewUri = link; } string content = "(no content)"; if (item.Content != null) { content = item.Content.Text; } else if (item.Summary != null) { content = item.Summary.Text; } /* * webView.Navigate(f.Link) では, * 上手くLink HTMLを拾えない * webView.NavigateToString(content) を使う */ //webView.Navigate(f.Link); webView.NavigateToString("<html><body>" + content + "</body></html>"); webView.Visibility = Visibility.Visible; await Task.Delay(0); }