public void NavigateTo(string pageKey, object parameter, HistoryBehavior historyBehavior, PreAppearingBehavior preAppearingBehavior = PreAppearingBehavior.Default) { Type pageType; if (pages.TryGetValue(pageKey, out pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType, args: parameter); CurrentPageKey = pageKey; ((IContentPageBase)displayPage)?.OnPreAppearing(preAppearingBehavior == PreAppearingBehavior.ClearData); if (historyBehavior == HistoryBehavior.ClearHistory) { displayPage.SetNavigationArgs(parameter); ((NavigationPage)MainPage).CurrentPage.Navigation.InsertPageBefore(displayPage, ((NavigationPage)MainPage).RootPage); MainPage.Navigation.PopToRootAsync(); } else { MainPage.Navigation.PushAsync(displayPage, parameter, animated: true); } } else { throw new ArgumentException( $"No such page: {pageKey}. Did you forget to call NavigationService.Configure?", nameof(pageKey)); } }
public void NavigateTo(string pageKey, object parameter = null, HistoryBehavior historyBehavior = HistoryBehavior.Default) { Type pageType; if (pages.TryGetValue(pageKey, out pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType); displayPage.SetNavigationArgs(parameter); if (historyBehavior == HistoryBehavior.ClearHistory) { MainPage.Navigation.InsertPageBefore(displayPage, MainPage.Navigation.NavigationStack[0]); // Since we want to clear history, removes all the other pages from the navigation stack. var existingPages = MainPage.Navigation.NavigationStack.ToList(); for (int i = 1; i < existingPages.Count; i++) { MainPage.Navigation.RemovePage(existingPages[i]); } } else { MainPage.Navigation.PushAsync(displayPage); } } else { throw new ArgumentException($"No such page: {pageKey}.", nameof(pageKey)); } }
public void NavigateTo(string pageKey, object parameter, HistoryBehavior historyBehavior, int?clearStackLevel = null) { if (pages.TryGetValue(pageKey, out var pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType); var currentPage = MainPage.Navigation.NavigationStack.LastOrDefault(); if (displayPage.GetType() == currentPage.GetType() && historyBehavior == HistoryBehavior.Default) { // Navigation to the same page type. Skips. return; } var navigation = MainPage.Navigation; if (historyBehavior == HistoryBehavior.ClearHistory) { if (clearStackLevel == null) { displayPage.SetNavigationArgs(parameter); navigation.InsertPageBefore(displayPage, MainPage.Navigation.NavigationStack[0]); var existingPages = navigation.NavigationStack.ToList(); // Since we want to clear history, removes all the other pages from the navigation stack. for (var i = 1; i < existingPages.Count; i++) { navigation.RemovePage(existingPages[i]); } } else { navigation.PushAsync(displayPage, parameter, animated: true); var existingPages = navigation.NavigationStack.ToList(); // Deletes the stack till to the specified depth. var startStackPoint = existingPages.Count - 2; for (var i = startStackPoint; i > startStackPoint - clearStackLevel; i--) { navigation.RemovePage(existingPages[i]); } } } else { // Simply pushes the page to the navigation stack. navigation.PushAsync(displayPage, parameter, animated: true); } } else { throw new ArgumentException( $"No such page: {pageKey}. Did you forget to call NavigationService.Configure?", nameof(pageKey)); } }
public void NavigateTo(string pageKey, object parameter, HistoryBehavior historyBehavior, int?clearStackLevel = null) { if (pages.TryGetValue(pageKey, out var pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType); var currentPage = MainPage.Navigation.NavigationStack.LastOrDefault(); if (displayPage.GetType() == currentPage.GetType() && historyBehavior == HistoryBehavior.Default) { // Navigation to the same page type. Skips. return; } var navigation = MainPage.Navigation; if (historyBehavior == HistoryBehavior.ClearHistory) { if (clearStackLevel == null) { displayPage.SetNavigationArgs(parameter); MainPage = new NavigationPage(displayPage); } else { navigation.PushAsync(displayPage, parameter, animated: true); // Deletes the stack till to the specified depth. var existingPages = navigation.NavigationStack.ToList(); var startStackPoint = existingPages.Count - 2; for (var i = startStackPoint; i > startStackPoint - clearStackLevel; i--) { navigation.RemovePage(existingPages[i]); } } } else { // Simply pushes the page to the navigation stack. navigation.PushAsync(displayPage, parameter, animated: true); } // After navigation, if the MainPage is a Master/Detail page, automatically closes the menu. if ((CurrentPage ?? Application.Current.MainPage) is MasterDetailPage page) { page.IsPresented = false; } } else { throw new ArgumentException( $"No such page: {pageKey}. Did you forget to call NavigationService.Configure?", nameof(pageKey)); } }
/// <summary> /// ヒストリーを追加する /// </summary> public void SaveHistoryBehaviorValue() { while (this.historyBehaviorValue.Count > this.historyIndex) { this.historyBehaviorValue.RemoveAt(this.historyIndex); } HistoryBehavior historyBehavior = new HistoryBehavior() { SelectionStart = base.SelectionStart, Text = base.Text }; this.historyBehaviorValue.Add(historyBehavior); if (this.historyBehaviorValue.Count > 10) { this.historyBehaviorValue.RemoveAt(0); } this.historyIndex = this.historyBehaviorValue.Count - 1; }
public void NavigateTo(string pageKey, object parameter = null, HistoryBehavior historyBehavior = HistoryBehavior.Default, PresentationBehavior present = PresentationBehavior.Normal) { Type pageType; if (pages.TryGetValue(pageKey, out pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType); displayPage.SetNavigationArgs(parameter); if (historyBehavior == HistoryBehavior.ClearHistory) { MainPage.Navigation.InsertPageBefore(displayPage, MainPage.Navigation.NavigationStack[0]); var existingPages = MainPage.Navigation.NavigationStack.ToList(); for (int i = 1; i < existingPages.Count; i++) { MainPage.Navigation.RemovePage(existingPages[i]); } } else { if (present == PresentationBehavior.Normal) { MainPage.Navigation.PushAsync(displayPage); } else { MainPage.Navigation.PushModalAsync(displayPage); } } } else { throw new ArgumentException($"No such page: {pageKey}.", nameof(pageKey)); } }
public void NavigateTo(string pageKey, object parameter = null, HistoryBehavior historyBehavior = HistoryBehavior.Default) { //System.Diagnostics.Debug.WriteLine("NavigateTo. PageKey: " + pageKey + " | parameter: " + (parameter ?? parameter.ToString())); Type pageType; if (pages.TryGetValue(pageKey, out pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType); displayPage.SetNavigationArgs(parameter); NavigationPage.SetHasNavigationBar(displayPage, false); HideMasterDetailMenu(); if (historyBehavior == HistoryBehavior.ClearHistory) { MainPage.Navigation.InsertPageBefore(displayPage, MainPage.Navigation.NavigationStack[0]); // Since we want to clear history, removes all the other pages from the navigation stack. var existingPages = MainPage.Navigation.NavigationStack.ToList(); for (int i = 1; i < existingPages.Count; i++) { MainPage.Navigation.RemovePage(existingPages[i]); } } else { MainPage.Navigation.PushAsync(displayPage, true); } } else { System.Diagnostics.Debug.WriteLine("No such page exception."); throw new ArgumentException($"No such page: {pageKey}.", nameof(pageKey)); } }
public void NavigateTo( string pageKey, Dictionary <string, string> parameter = null, HistoryBehavior historyBehavior = HistoryBehavior.Default) { if (Pages.TryGetValue(pageKey, out Type pageType)) { var displayPage = (Page)Activator.CreateInstance(pageType); displayPage.SetNavigationArgs(parameter); if (historyBehavior == HistoryBehavior.ClearHistory) { _mainPage.Navigation.InsertPageBefore(displayPage, _mainPage.Navigation.NavigationStack[0]); // The transitions sucks when using this method. ////_mainPage.Navigation.PopToRootAsync(); var existingPages = _mainPage.Navigation.NavigationStack.ToList(); for (int i = 1; i < existingPages.Count; i++) { ////_mainPage.Navigation.RemovePage(existingPages[i]); _mainPage.Navigation.PopAsync(); } } else if (historyBehavior == HistoryBehavior.ClearTop) { throw new NotImplementedException("Has not made clear top yet"); } else { _mainPage.Navigation.PushAsync(displayPage); } } else { throw new ArgumentException($"No such page: {pageKey}.", nameof(pageKey)); } }
public void NavigateTo(string pageKey, HistoryBehavior historyBehavior) => NavigateTo(pageKey, null, historyBehavior);
public void NavigateTo(string pageKey, HistoryBehavior historyBehavior, PreAppearingBehavior preAppearingBehavior) => NavigateTo(pageKey, null, historyBehavior, preAppearingBehavior);
public void NavigateTo(string pageKey, object parameter, HistoryBehavior historyBehavior) => NavigateTo(pageKey, parameter, historyBehavior, null);
public void NavigateTo(string pageKey, HistoryBehavior historyBehavior, int?clearStackLevel = null) => NavigateTo(pageKey, null, historyBehavior, clearStackLevel);
/// <summary> /// Defines a new <see cref="NavigationProperties"/>. /// </summary> /// <param name="overlayMode">The <see cref="LayerBehavior"/> mode that should be used to present the navigated content.</param> /// <param name="historyMode">The <see cref="HistoryBehavior"/> mode that should be used by the <see cref="INavigationHistory"/> to handle the navigation stack.</param> public NavigationProperties(LayerBehavior overlayMode, HistoryBehavior historyMode) { LayerMode = overlayMode; HistoryMode = historyMode; }