public NavigatingEventArgs(DeferralManager manager, NavigatingCancelEventArgs e, Page page, object parameter) : this(manager) { NavigationMode = e.NavigationMode; PageType = e.SourcePageType; Page = page; Parameter = parameter; }
private async void FacadeNavigatingCancelEventHandler(object sender, NavigatingCancelEventArgs e) { DebugWrite(); object parameter = null; try { parameter = SerializationService.Deserialize(e.Parameter?.ToString()); } catch (Exception ex) { throw new Exception("Your parameter must be serializable. If it isn't, then use SessionState.", ex); } var deferral = new DeferralManager(); var args = new NavigatingEventArgs(deferral, e, Content as Page, parameter); if (NavigationModeHint != NavigationMode.New) args.NavigationMode = NavigationModeHint; NavigationModeHint = NavigationMode.New; _navigatingEventHandlers.ForEach(x => x(this, args)); await deferral.WaitForDeferralsAsync(); e.Cancel = args.Cancel; }
public DeferredEventArgs(DeferralManager manager) { Manager = manager; }
public async Task<bool> NavingFromCancelsAsync(object viewmodel, NavigationMode mode, Page sourcePage, Type sourceType, object sourceParameter, Page targetPage, Type targetType, object targetParameter, bool suspending) { Services.NavigationService.NavigationService.DebugWrite(); if (sourcePage == null) { return false; } else if (viewmodel == null) { return false; } else if (viewmodel is Classic.INavigatingAwareAsync) { var deferral = new DeferralManager(); var navigatingEventArgs = new Classic.NavigatingEventArgs(deferral) { Page = sourcePage, PageType = sourcePage?.GetType(), Parameter = sourceParameter, NavigationMode = mode, TargetPageType = targetType, TargetPageParameter = targetParameter, Suspending = suspending, }; try { var vm = viewmodel as Classic.INavigatingAwareAsync; await vm?.OnNavigatingFromAsync(navigatingEventArgs); await deferral.WaitForDeferralsAsync(); } catch { Debugger.Break(); } return navigatingEventArgs.Cancel; } else if (viewmodel is Portable.IConfirmNavigationAsync) { var parameters = new Portable.NavigationParameters(); parameters.Add("NavigationMode", mode.ToPrismNavigationMode()); parameters.Add("SourceType", sourceType); parameters.Add("SourceParameter", sourceParameter); parameters.Add("TargetType", targetType); parameters.Add("TargetParameter", targetParameter); parameters.Add("Suspending", suspending); var vm = viewmodel as Portable.IConfirmNavigationAsync; return !await vm?.CanNavigateAsync(parameters); } else { return true; } }
public NavigatingEventArgs(DeferralManager manager) : base() { Manager = manager; }