/// <summary> /// Navigates forward. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="navigator">The stack navigator.</param> /// <param name="ct">The cancellation token.</param> /// <param name="viewModelProvider">The method to invoke to instanciate the ViewModel.</param> /// <param name="suppressTransition">Whether to suppress the navigation transition.</param> /// <returns>The ViewModel instance of the active page after the navigation operation.</returns> public static async Task <TViewModel> Navigate <TViewModel>(this IStackNavigator navigator, CancellationToken ct, Func <TViewModel> viewModelProvider, bool suppressTransition = false) where TViewModel : INavigableViewModel { return((TViewModel)await navigator.Navigate(ct, StackNavigatorRequest.GetNavigateRequest(viewModelProvider, suppressTransition))); }
/// <summary> /// Creates a new instance of <see cref="NavigationStackEntry"/>. /// </summary> /// <param name="request">The navigation request.</param> /// <param name="viewModel">The ViewModel.</param> /// <param name="view">The view.</param> public NavigationStackEntry(StackNavigatorRequest request, INavigableViewModel viewModel, object view) { Request = request; ViewModel = viewModel; View = view; }
/// <summary> /// Processes a <see cref="StackNavigatorRequest"/> based on its <see cref="StackNavigatorRequestType"/>. /// </summary> /// <param name="stackNavigator">The stack navigator.</param> /// <param name="ct">The cancellation token.</param> /// <param name="request">The request to process.</param> public static Task ProcessRequest(this IStackNavigator stackNavigator, CancellationToken ct, StackNavigatorRequest request) { switch (request.RequestType) { case StackNavigatorRequestType.NavigateForward: return(stackNavigator.Navigate(ct, request)); case StackNavigatorRequestType.NavigateBack: return(stackNavigator.NavigateBack(ct)); case StackNavigatorRequestType.Clear: return(stackNavigator.Clear(ct)); case StackNavigatorRequestType.RemoveEntry: return(stackNavigator.RemoveEntries(ct, request.EntryIndexesToRemove)); default: throw new NotSupportedException($"The request type '{request.RequestType}' is not supported."); } }
public StackNavigatorState(IReadOnlyList <NavigationStackEntry> stack, NavigatorRequestState lastRequestState, StackNavigatorRequest lastRequest) { Stack = stack; LastRequestState = lastRequestState; LastRequest = lastRequest; }