/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property provides the group to be displayed.</param> protected override async Task OnNavigatedTo(AlternativeNavigationEventArgs e) { // Returning to a cached page through navigation shouldn't trigger state loading if (_pageKey != null) { return; } var frameState = SuspensionManager.SessionStateForFrame(this.Frame); _pageKey = "Page-" + this.Frame.BackStackDepth; if (e.NavigationMode == NavigationMode.New) { // Clear existing state for forward navigation when adding a new page to the // navigation stack var nextPageKey = _pageKey; int nextPageIndex = this.Frame.BackStackDepth; while (frameState.Remove(nextPageKey)) { nextPageIndex++; nextPageKey = "Page-" + nextPageIndex; } // Pass the navigation parameter to the new page this.LoadState(e.Parameter, null); } else { // Pass the navigation parameter and preserved page state to the page, using // the same strategy for loading suspended state and recreating pages discarded // from cache this.LoadState(e.Parameter, (Dictionary <String, Object>)frameState[_pageKey]); } }
#pragma warning restore 1998 protected override async Task OnNavigatingTo(AlternativeNavigationEventArgs e) { _isPreloaded = false; _parameter = (int)e.Parameter; ParameterTextBlock.Text = "Parameter: " + _parameter; await base.OnNavigatingTo(e); }
#pragma warning disable 1998 protected override async Task OnNavigatedTo(AlternativeNavigationEventArgs e) { GC.Collect(); #pragma warning disable 4014 base.OnNavigatedTo(e); #pragma warning restore 4014 }
#pragma warning disable 1998 /// <summary> /// Invoked when this page will no longer be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property provides the group to be displayed.</param> protected override async Task OnNavigatedFrom(AlternativeNavigationEventArgs e) { var frameState = SuspensionManager.SessionStateForFrame(this.Frame); var pageState = new Dictionary <String, Object>(); this.SaveState(pageState); frameState[_pageKey] = pageState; }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously protected override async Task OnNavigatedToAsync(AlternativeNavigationEventArgs e) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { GC.Collect(); #pragma warning disable 4014 base.OnNavigatedToAsync(e); #pragma warning restore 4014 WindowTitleBar.SetText("WinRT XAML Toolkit Samples", true); }
protected override Task OnNavigatedToAsync(AlternativeNavigationEventArgs e) { var title = e.Parameter as string; WindowTitleBar.SetText("WinRT XAML Toolkit - " + title, true); //this.TitleTextBlock.Text = title; var sampleButton = MainPageViewModel.Instance.UngroupedSamples.First(s => s.Caption == title); var content = (FrameworkElement)Activator.CreateInstance(sampleButton.ViewType); this.ContentGrid.Children.Add(content); AddHandler(Control.KeyDownEvent, new KeyEventHandler(TestPage_OnKeyDown), true); Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; return(base.OnNavigatedToAsync(e)); }
protected override Task OnNavigatedFromAsync(AlternativeNavigationEventArgs e) { RemoveHandler(Control.KeyDownEvent, new KeyEventHandler(TestPage_OnKeyDown)); Window.Current.CoreWindow.KeyDown -= CoreWindow_KeyDown; return(base.OnNavigatedFromAsync(e)); }
protected override async Task OnNavigatedTo(AlternativeNavigationEventArgs e) { await this.Frame.Preload(typeof(AlternativeFrameTestPageSubPage3), _parameter + 1); }
protected override async Task OnNavigatedFromAsync(AlternativeNavigationEventArgs e) { await base.OnNavigatedFromAsync(e); }
#pragma warning disable 1998 protected override async Task OnNavigatedTo(AlternativeNavigationEventArgs e) { GC.Collect(); base.OnNavigatedTo(e); }