/// <summary> /// Overridden OnNavigatedTo handler /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (isNewInstance) { pageId = int.Parse(NavigationContext.QueryString["pageId"]); page = RSSService.GetRSSPage(pageId); if (page != null) { PageTitle.Text = page.Title; subscriptionsListBox.ItemsSource = page.Feeds; } isNewInstance = false; } }
/// <summary> /// Overridden OnNavigatedTo handler /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (isNewInstance) { originalFeedId = feedId = int.Parse(NavigationContext.QueryString["id"]); pageId = int.Parse(NavigationContext.QueryString["page"]); page = RSSService.GetRSSPage(pageId); InitializePivotViews(page); // Switch to the previously selected PivotItem, if it has been stored if (State.ContainsKey("feedPivotIndex")) { RSSItemsPivot.SelectedIndex = (int)State["feedPivotIndex"]; } isNewInstance = false; } }
/// <summary> /// Method that initializes all pivot items /// </summary> /// <param name="page"></param> private void InitializePivotViews(RSSPage page) { // Perform initialization only on the 1st time if (RSSItemsPivot.Items.Count == 0) { // Initialize PivotItems // Initialize them starting from the one that was tapped // so that when the PivotItems show up, the active one // is already the tapped one. Otherwise we'd have to wait // for all of the PivotItems to load and then change the // SelectedIndex, which would result in animation in the // Pivot control. for (int i = 0; i < page.Feeds.Count; i++) { int j = originalFeedId + i; if (j >= page.Feeds.Count) { j = j % page.Feeds.Count; } CreatePivotItem(page.Feeds[j]); } } }