protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { Bookitem = e.Parameter as BookItem; bookDetailsGrid.DataContext = Bookitem; localTitle = MainPage.TitleTextBlock.Text = Bookitem.Title; var htmlPage = await HTMLParser.Instance.GetHtml(Bookitem.Interlinkage); if (htmlPage == null) { await MainPage.PopMessageDialog("网络或服务器故障!"); return; } HtmlDoc.LoadHtml(htmlPage); var contentNode = HtmlDoc.GetElementbyId("content"); var summary = contentNode.ChildNodes[1].ChildNodes[7].ChildNodes[1].ChildNodes[3].ChildNodes[13].InnerText; readLinkage = contentNode.ChildNodes[1].ChildNodes[11].ChildNodes[1].ChildNodes[1].ChildNodes[1].ChildNodes[3].ChildNodes[0].Attributes["href"].Value; Bookitem.Summary = summary.Replace(" ", " "); Bookitem.ReadLinkage = readLinkage; try { var localFolder = ApplicationData.Current.LocalCacheFolder; var file = await localFolder.GetFileAsync("collectedNovels.txt"); var collectedNovels = await FileIO.ReadTextAsync(file); if (collectedNovels.Contains(Bookitem.BID)) { CollectButton.Content = "取消收藏"; } else { CollectButton.Content = "添加收藏"; } } catch (Exception) { CollectButton.Content = "添加收藏"; } summaryTextBlock.Text = Bookitem.Summary; htmlPage = await HTMLParser.Instance.GetHtml(Bookitem.ReadLinkage); if (htmlPage == null) { await MainPage.PopMessageDialog("已取消收藏!"); } else { BookIndexes.Clear(); BookIndexParser.Instance.GetBookIndexes(htmlPage, BookIndexes); MainPage.ProgressRing.IsActive = false; MainPage.ProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } } else if (e.NavigationMode == NavigationMode.Back) { MainPage.TitleTextBlock.Text = localTitle; MainPage.ProgressRing.IsActive = false; MainPage.ProgressRing.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } }