private void newViewModel_RequestNavigateBackTo(object sender, NavigationBackEventArgs e) { if (e.Parameters != null) { NavigationViewModelBase.NavigationState["back_params"] = e.Parameters; } JournalEntry target = null; var backStackList = NavigationService.BackStack.ToList(); foreach (var backStack in backStackList) { var uri = backStack.Source.ToString(); if (uri.Contains(e.ViewModel.ViewHint)) { target = backStack; break; } } if (target == null) { // We can't find anything in the backlog e.ViewModel.RollbackFromNavigateBackTo(e.Parameters); return; } var index = backStackList.IndexOf(target); for (int i = 0; i < index; i++) { NavigationService.RemoveBackEntry(); } if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }
private void newViewModel_RequestNavigateBackTo(object sender, NavigationBackEventArgs e) { if (e.Parameters != null) { NavigationViewModelBase.NavigationState["back_params"] = e.Parameters; } JournalEntry target = null; var backStackList = NavigationService.BackStack.ToList(); foreach (var backStack in backStackList) { var uri = backStack.Source.ToString(); var rootFrame = Application.Current.RootVisual as Frame; if (rootFrame != null) { if (rootFrame.UriMapper != null) { uri = rootFrame.UriMapper.MapUri(backStack.Source).ToString(); } } if (uri.Contains(e.ViewModel.ViewHint)) { target = backStack; break; } } if (target == null) { // We can't find anything in the backlog e.ViewModel.RollbackFromNavigateBackTo(e.Parameters); return; } var index = backStackList.IndexOf(target); for (int i = 0; i < index; i++) { NavigationService.RemoveBackEntry(); } if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }