private void Page_Loaded(object sender, RoutedEventArgs e) { Window.Current.SetTitleBar(GridTitleBar); // 禁用标题栏的后退按钮 SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; MainPage.rootPage.MyCommandBar.Visibility = Visibility.Visible; MainPage.rootPage.RefreshAppBarButton.IsEnabled = true; if (OAuthHelper.IsLogin) { if (!HomePagePivot.Items.Cast <PivotItem>().Any(p => p.Name == "CollectionItem")) { HomePagePivot.Items.Insert(0, CollectionItem); } if (!HomePagePivot.Items.Cast <PivotItem>().Any(p => p.Name == "ProgressItem")) { HomePagePivot.Items.Insert(0, ProgressItem); HomePagePivot.SelectedIndex = 0; ProgressPageFrame.Navigate(typeof(ProgressPage), null, new SuppressNavigationTransitionInfo()); } } else { // 在进度页与收藏页任一页面存在时运行 if (HomePagePivot.Items.Cast <PivotItem>().Any(p => p.Name == "ProgressItem") || HomePagePivot.Items.Cast <PivotItem>().Any(p => p.Name == "CollectionItem")) { HomePagePivot.Items.Remove(ProgressItem); HomePagePivot.Items.Remove(CollectionItem); TimeLinePageFrame.Navigate(typeof(TimeLinePage), null, new SuppressNavigationTransitionInfo()); } } }
private void HomePagePivot_SelectionChanged(object sender, SelectionChangedEventArgs e) { var pivot = sender as Pivot; var pivotItem = pivot.SelectedItem as PivotItem; var frame = pivotItem.Content as Frame; MainPage.rootPage.RefreshAppBarButton.Tag = pivotItem.Header; if (frame.Content == null) { switch (pivotItem.Header) { case "进度": ProgressPageFrame.Navigate(typeof(ProgressPage), null, new SuppressNavigationTransitionInfo()); break; case "收藏": CollectionPageFrame.Navigate(typeof(CollectionPage), null, new SuppressNavigationTransitionInfo()); break; case "时间表": TimeLinePageFrame.Navigate(typeof(TimeLinePage), null, new SuppressNavigationTransitionInfo()); break; default: break; } } }