#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 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 //SearchPane.GetForCurrentView().ShowOnKeyboardInput = true; }
protected override Task OnNavigatedTo(AlternativeNavigationEventArgs e) { var title = e.Parameter as string; 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); return base.OnNavigatedTo(e); }
protected override async Task OnNavigatedFrom(AlternativeNavigationEventArgs e) { await base.OnNavigatedFrom(e); if (DisableSearchPaneOnFocusHandler.IsSearchEnabled) { SearchPane.GetForCurrentView().ShowOnKeyboardInput = false; } }
private async Task OnNavigated(AlternativeNavigationEventArgs args) { AlternativeNavigationEventHandler handler = this.Navigated; if (handler != null) { await handler(this, args); } }
#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 virtual async Task OnNavigatingTo(AlternativeNavigationEventArgs e) { this.NavigationState = NavigationState.NavigatingTo; }
private async Task <bool> NavigateCore( Type sourcePageType, object parameter, NavigationMode navigationMode) { _isNavigating = true; this.CanNavigate = false; this.CanGoBack = false; this.CanGoForward = false; this.IsHitTestVisible = false; // Make sure we run on UI thread if (!Dispatcher.HasThreadAccess) { Task <bool> navigateCoreTask = null; await Dispatcher.RunAsync( CoreDispatcherPriority.High, () => navigateCoreTask = NavigateCore(sourcePageType, parameter, navigationMode)); return(await navigateCoreTask); } try { await _waitForApplyTemplateTaskSource.Task; await this.WaitForLoadedAsync(); AlternativePage currentPage = null; #region OnNavigatingFrom part if (_currentPagePresenter != null) { currentPage = (AlternativePage)_currentPagePresenter.Content; var cancelArgs = new AlternativeNavigatingCancelEventArgs( navigationMode, sourcePageType); await this.OnNavigating(cancelArgs); if (!cancelArgs.Cancel) { await currentPage.OnNavigatingFromInternalAsync(cancelArgs); } if (cancelArgs.Cancel) { return(false); } } #endregion #region Initializing new page instance part var je = new JournalEntry { SourcePageType = sourcePageType, Parameter = parameter }; AlternativePage newPage; ContentPresenter newPagePresenter; if (_preloadedPageCache.ContainsKey(je)) { newPagePresenter = _preloadedPageCache[je]; newPage = (AlternativePage)newPagePresenter.Content; _preloadedPageCache.Remove(je); } else { newPage = _frameCache.Get(je.SourcePageType); if (newPage == null) { throw new InvalidOperationException( "Pages used in AlternativeFrame need to be of AlternativePage type."); } newPage.Frame = this; newPagePresenter = new ContentPresenter { Style = PagePresenterStyle }; newPagePresenter.Content = newPage; _pagePresentersPanel.Children.Add(newPagePresenter); } newPagePresenter.Opacity = 0.005; await UnloadAllPreloadedAsync(); #endregion #region OnNavigatingTo part var args = new AlternativeNavigationEventArgs( newPage.Content, navigationMode, je.Parameter, je.SourcePageType); await newPage.OnNavigatingToInternalAsync(args); #endregion #region Journal Bookeeping part switch (navigationMode) { case NavigationMode.New: this.ForwardStack.Clear(); if (this.CurrentJournalEntry != null) { this.BackStack.Push(this.CurrentJournalEntry); } break; case NavigationMode.Forward: this.ForwardStack.Pop(); if (this.CurrentJournalEntry != null) { this.BackStack.Push(this.CurrentJournalEntry); } break; case NavigationMode.Back: this.BackStack.Pop(); if (this.CurrentJournalEntry != null) { this.ForwardStack.Push(this.CurrentJournalEntry); } break; } this.CurrentJournalEntry = je; #endregion #region OnNavigated~() calls this.UpdateCans(); if (currentPage != null) { await currentPage.OnNavigatedFromInternalAsync(args); } await this.OnNavigated(args); await newPage.OnNavigatedToInternalAsync(args); #endregion #region Transition part await newPagePresenter.WaitForLoadedAsync(); await newPagePresenter.WaitForNonZeroSizeAsync(); if (this.ShouldWaitForImagesToLoad == true && newPage.ShouldWaitForImagesToLoad != false || newPage.ShouldWaitForImagesToLoad == true && this.ShouldWaitForImagesToLoad != false) { await newPage.WaitForImagesToLoad(WaitForImagesToLoadTimeout); } newPagePresenter.Opacity = 1.0; if (navigationMode == NavigationMode.Back) { await TransitionBackward( currentPage, newPage, _currentPagePresenter, newPagePresenter); } else { await TransitionForward( currentPage, newPage, _currentPagePresenter, newPagePresenter); } if (_currentPagePresenter != null) { _pagePresentersPanel.Children.Remove(_currentPagePresenter); _frameCache.Store(currentPage); } _currentPagePresenter = newPagePresenter; #endregion return(true); } finally { this.IsHitTestVisible = true; _isNavigating = false; this.UpdateCans(); //DC.TraceLocalized(GetNavigationState()); } }
public async Task <bool> GoBack() { if (_isNavigating) { throw new InvalidOperationException("Navigation already in progress."); } _isNavigating = true; this.CanNavigate = false; this.CanGoBack = false; try { await this.WaitForLoadedAsync(); AlternativePage currentPage = null; var currentJe = this.BackStack.Pop(); var je = BackStack.Peek(); if (_currentPagePresenter != null) { currentPage = (AlternativePage)_currentPagePresenter.Content; var cancelArgs = new AlternativeNavigatingCancelEventArgs( NavigationMode.Back, je.Type); await currentPage.OnNavigatingFromInternal(cancelArgs); if (cancelArgs.Cancel) { this.BackStack.Push(currentJe); return(false); } } AlternativePage newPage; ContentPresenter newPagePresenter; if (_preloadedPageCache.ContainsKey(je)) { newPagePresenter = _preloadedPageCache[je]; newPage = (AlternativePage)newPagePresenter.Content; _preloadedPageCache.Remove(je); } else { newPage = (AlternativePage)Activator.CreateInstance(je.Type); newPage.Frame = this; newPagePresenter = new ContentPresenter { Style = PagePresenterStyle }; newPagePresenter.Content = newPage; _pagePresentersPanel.Children.Add(newPagePresenter); } newPagePresenter.Opacity = 0.005; await UnloadPreloadedPages(); var args = new AlternativeNavigationEventArgs( newPage.Content, NavigationMode.New, je.Parameter, je.Type); await newPage.OnNavigatingToInternal(args); await newPagePresenter.WaitForLoadedAsync(); await newPagePresenter.WaitForNonZeroSizeAsync(); newPagePresenter.Opacity = 1.0; if (this.PageTransition != null) { await this.PageTransition.TransitionBackward(_currentPagePresenter, newPagePresenter); } if (currentPage != null) { await currentPage.OnNavigatedFromInternal(args); _pagePresentersPanel.Children.Remove(_currentPagePresenter); } _currentPagePresenter = newPagePresenter; await newPage.OnNavigatedToInternal(args); return(true); } finally { _isNavigating = false; this.CanNavigate = true; this.CanGoBack = this.BackStack.Count > 1; } }
/// <summary> /// When overriden in child classes - enables to perform limited processing before a navigation progresses. /// </summary> /// <param name="e">The <see cref="AlternativeNavigationEventArgs"/> instance containing the event data.</param> /// <returns></returns> #pragma warning disable 1998 protected virtual async Task OnNavigatingToAsync(AlternativeNavigationEventArgs e) #pragma warning restore 1998 { this.NavigationState = NavigationState.NavigatingTo; }
internal async Task OnNavigatedFromInternal(AlternativeNavigationEventArgs e) { this.NavigationState = NavigationState.NavigatedFrom; await OnNavigatedFrom(e); }
#pragma warning disable 1998 protected override async Task OnNavigatedTo(AlternativeNavigationEventArgs e) { GC.Collect(); base.OnNavigatedTo(e); }
protected override async Task OnNavigatedFromAsync(AlternativeNavigationEventArgs e) { await base.OnNavigatedFromAsync(e); }
protected virtual async Task OnNavigatingTo(AlternativeNavigationEventArgs e) { }
protected override async Task OnNavigatedToAsync(AlternativeNavigationEventArgs e) { await this.Frame.PreloadAsync(typeof(AlternativeFrameTestPageSubPage3), _parameter + 1); }
internal async Task OnNavigatedToInternal(AlternativeNavigationEventArgs e) { await OnNavigatedTo(e); }
/// <summary> /// Invoked when the Page is loaded and becomes the current source of a parent AlternativeFrame. /// </summary> /// <param name="e"> /// Event data that can be examined by overriding code. The event data is representativeThe <see cref="WinRTXamlToolkit.Controls.AlternativeNavigationEventArgs"/> instance containing the event data. /// of the pending navigation that will load the current Page. Usually the most /// relevant property to examine is Parameter. /// </param> /// <returns></returns> #pragma warning disable 1998 protected virtual async Task OnNavigatedToAsync(AlternativeNavigationEventArgs e) #pragma warning restore 1998 { }
// // Summary: // Invoked when the Page is loaded and becomes the current source of a parent // Frame. // // Parameters: // e: // Event data that can be examined by overriding code. The event data is representative // of the pending navigation that will load the current Page. Usually the most // relevant property to examine is Parameter. protected virtual async Task OnNavigatedTo(AlternativeNavigationEventArgs e) { }
internal async Task OnNavigatedToInternalAsync(AlternativeNavigationEventArgs e) { this.NavigationState = NavigationState.NavigatedTo; await OnNavigatedToAsync(e); }
public async Task<bool> GoBack() { if (_isNavigating) { throw new InvalidOperationException("Navigation already in progress."); } _isNavigating = true; this.CanNavigate = false; this.CanGoBack = false; try { await this.WaitForLoadedAsync(); AlternativePage currentPage = null; var currentJe = this.BackStack.Pop(); var je = BackStack.Peek(); if (_currentPagePresenter != null) { currentPage = (AlternativePage)_currentPagePresenter.Content; var cancelArgs = new AlternativeNavigatingCancelEventArgs( NavigationMode.Back, je.Type); await currentPage.OnNavigatingFromInternal(cancelArgs); if (cancelArgs.Cancel) { this.BackStack.Push(currentJe); return false; } } AlternativePage newPage; ContentPresenter newPagePresenter; if (_preloadedPageCache.ContainsKey(je)) { newPagePresenter = _preloadedPageCache[je]; newPage = (AlternativePage)newPagePresenter.Content; _preloadedPageCache.Remove(je); } else { newPage = (AlternativePage)Activator.CreateInstance(je.Type); newPage.Frame = this; newPagePresenter = new ContentPresenter { Style = PagePresenterStyle }; newPagePresenter.Content = newPage; _pagePresentersPanel.Children.Add(newPagePresenter); } newPagePresenter.Opacity = 0.005; await UnloadPreloadedPages(); var args = new AlternativeNavigationEventArgs( newPage.Content, NavigationMode.New, je.Parameter, je.Type); await newPage.OnNavigatingToInternal(args); await newPagePresenter.WaitForLoadedAsync(); await newPagePresenter.WaitForNonZeroSizeAsync(); newPagePresenter.Opacity = 1.0; if (this.PageTransition != null) { await this.PageTransition.TransitionBackward(_currentPagePresenter, newPagePresenter); } if (currentPage != null) { await currentPage.OnNavigatedFromInternal(args); _pagePresentersPanel.Children.Remove(_currentPagePresenter); } _currentPagePresenter = newPagePresenter; await newPage.OnNavigatedToInternal(args); return true; } finally { _isNavigating = false; this.CanNavigate = true; this.CanGoBack = this.BackStack.Count > 1; } }
private async Task<bool> NavigateCore( Type sourcePageType, object parameter, NavigationMode navigationMode) { _isNavigating = true; this.CanNavigate = false; this.CanGoBack = false; this.CanGoForward = false; this.IsHitTestVisible = false; // Make sure we run on UI thread if (!Dispatcher.HasThreadAccess) { Task<bool> navigateCoreTask = null; await Dispatcher.RunAsync( CoreDispatcherPriority.High, () => navigateCoreTask = NavigateCore(sourcePageType, parameter, navigationMode)); return await navigateCoreTask; } try { await _waitForApplyTemplateTaskSource.Task; await this.WaitForLoadedAsync(); AlternativePage currentPage = null; #region OnNavigatingFrom part if (_currentPagePresenter != null) { currentPage = (AlternativePage)_currentPagePresenter.Content; var cancelArgs = new AlternativeNavigatingCancelEventArgs( navigationMode, sourcePageType); await this.OnNavigating(cancelArgs); if (!cancelArgs.Cancel) { await currentPage.OnNavigatingFromInternal(cancelArgs); } if (cancelArgs.Cancel) { return false; } } #endregion #region Initializing new page instance part var je = new JournalEntry { SourcePageType = sourcePageType, Parameter = parameter }; AlternativePage newPage; ContentPresenter newPagePresenter; if (_preloadedPageCache.ContainsKey(je)) { newPagePresenter = _preloadedPageCache[je]; newPage = (AlternativePage)newPagePresenter.Content; _preloadedPageCache.Remove(je); } else { newPage = _frameCache.Get(je.SourcePageType); if (newPage == null) { throw new InvalidOperationException( "Pages used in AlternativeFrame need to be of AlternativePage type."); } newPage.Frame = this; newPagePresenter = new ContentPresenter { Style = PagePresenterStyle }; newPagePresenter.Content = newPage; _pagePresentersPanel.Children.Add(newPagePresenter); } newPagePresenter.Opacity = 0.005; await UnloadAllPreloaded(); #endregion #region OnNavigatingTo part var args = new AlternativeNavigationEventArgs( newPage.Content, navigationMode, je.Parameter, je.SourcePageType); await newPage.OnNavigatingToInternal(args); #endregion #region Journal Bookeeping part switch (navigationMode) { case NavigationMode.New: this.ForwardStack.Clear(); if (this.CurrentJournalEntry != null) { this.BackStack.Push(this.CurrentJournalEntry); } break; case NavigationMode.Forward: this.ForwardStack.Pop(); if (this.CurrentJournalEntry != null) { this.BackStack.Push(this.CurrentJournalEntry); } break; case NavigationMode.Back: this.BackStack.Pop(); if (this.CurrentJournalEntry != null) { this.ForwardStack.Push(this.CurrentJournalEntry); } break; } this.CurrentJournalEntry = je; #endregion #region OnNavigated~() calls await this.OnNavigated(args); if (currentPage != null) { await currentPage.OnNavigatedFromInternal(args); } await newPage.OnNavigatedToInternal(args); #endregion #region Transition part await newPagePresenter.WaitForLoadedAsync(); await newPagePresenter.WaitForNonZeroSizeAsync(); if (this.ShouldWaitForImagesToLoad == true && newPage.ShouldWaitForImagesToLoad != false || newPage.ShouldWaitForImagesToLoad == true && this.ShouldWaitForImagesToLoad != false) { await newPage.WaitForImagesToLoad(WaitForImagesToLoadTimeout); } newPagePresenter.Opacity = 1.0; if (navigationMode == NavigationMode.Back) { await TransitionBackward( currentPage, newPage, _currentPagePresenter, newPagePresenter); } else { await TransitionForward( currentPage, newPage, _currentPagePresenter, newPagePresenter); } if (_currentPagePresenter != null) { _pagePresentersPanel.Children.Remove(_currentPagePresenter); _frameCache.Store(currentPage); } _currentPagePresenter = newPagePresenter; #endregion return true; } finally { this.IsHitTestVisible = true; _isNavigating = false; this.CanNavigate = true; this.CanGoBack = this.BackStack.Count > 0; this.CanGoForward = this.ForwardStack.Count > 0; //DC.TraceLocalized(GetNavigationState()); } }