/// <summary> /// navigate to as an asynchronous operation. /// </summary> /// <typeparam name="TView">The type of the t view.</typeparam> /// <param name="options">The options.</param> /// <returns>Task.</returns> public async Task NavigateToAsync <TView>(INavigationOptions options = null) where TView : class { var p = Resolver.Resolve <TView>() ?? DependencyService.Get <TView>(); if (p == null) { throw new ArgumentNullException(nameof(TView), "View/Page not registered in IOC framework"); } await NavigateToAsync(p, options).ConfigureAwait(true); }
public async Task NavigateToAsync <TView>(TView view, INavigationOptions options = null) where TView : class { if (view == null) { throw new ArgumentNullException(nameof(view), "View/Page must be specified"); } var p = view as Page; if (options?.ViewModel != null && (p.BindingContext == null || !p.BindingContext.Equals(options?.ViewModel))) { p.BindingContext = options.ViewModel; } switch (options?.NavigationAction) { case NavigationActionTypes.PopCurrentBefore: { await PopAsync(options.Animated).ConfigureAwait(true); } break; case NavigationActionTypes.PopToRootBefore: await PopToRootAsync(options.Animated).ConfigureAwait(true); break; } if (options?.DisableBackButton == true) { NavigationPage.SetHasBackButton(p, options.DisableBackButton); } if (options?.Modal == true) { await PushModalAsync(p, options?.Animated ?? true); } else { await PushAsync(p, options?.Animated ?? true); } }