/// <summary>
        /// Closes the window that is managed by this navigation service.
        /// </summary>
        /// <param name="isCancellable">Determines whether the closing of the application can be cancelled by the view model.</param>
        /// <param name="navigationReason">The navigation reason that is sent to the view model.</param>
        /// <returns>Returns a value that determines whether the window was closed or its closing was cancelled. If <see cref="p:isCancellable"/> is set to <c>false</c>, <c>NavigationResult.Navigated</c> is always returned.</returns>
        internal async Task <NavigationResult> CloseWindowAsync(bool isCancellable, NavigationReason navigationReason)
        {
            // Creates new event arguments for the navigation events
            NavigationEventArgs eventArguments = null;

            // Checks if the current view model exists, if so then its life-cycle events must be invoked
            if (this.CurrentViewModel != null)
            {
                // Checks if the window supports navigation and if the the current view has a view model, if so, then the on navigate from event is raised for the view model of the current view
                eventArguments = new NavigationEventArgs(navigationReason);
                await this.CurrentViewModel.OnNavigateFromAsync(eventArguments);

                if (eventArguments.Cancel && isCancellable && navigationReason != NavigationReason.WindowClosed)
                {
                    return(NavigationResult.Canceled);
                }

                // Deactivates the view model of the current view and disposes of it
                await this.CurrentViewModel.OnDeactivateAsync();

                this.CurrentViewModel.Dispose();
            }

            // Clears the navigation stack
            await this.ClearNavigationStackAsync();

            // Closes the window
            this.window.Close();

            // Since the window was closed successfully, a positive result is returned
            return(NavigationResult.Navigated);
        }
 /// <summary>
 /// Initializes a new <see cref="NavigationEventArgs"/> instance.
 /// </summary>
 /// <param name="reason">The reason of the navigation.</param>
 public NavigationEventArgs(NavigationReason reason)
 {
     this.Reason = reason;
 }
Beispiel #3
0
        public async Task <NavigateFocusResult> NavigateFocusAsync(NavigationReason reason, Rect origin, Guid guid)
        {
            await Task.Delay(10);

            return(new NavigateFocusResult());
        }
 /// <summary>
 /// Initializes a new <see cref="NavigationEventArgs"/> instance.
 /// </summary>
 /// <param name="reason">The reason of the navigation.</param>
 public NavigationEventArgs(NavigationReason reason)
 {
     this.Reason = reason;
 }
Beispiel #5
0
 /// <summary>
 /// Closes the window that is managed by this navigation service.
 /// </summary>
 /// <param name="isCancellable">Determines whether the closing of the application can be cancelled by the view model.</param>
 /// <param name="navigationReason">The navigation reason that is sent to the view model.</param>
 /// <returns>Returns a value that determines whether the window was closed or its closing was cancelled. If <see cref="p:isCancellable"/> is set to <c>false</c>, <c>NavigationResult.Navigated</c> is always returned.</returns>
 internal Task <NavigationResult> CloseWindowAsync(bool isCancellable, NavigationReason navigationReason) => this.CloseWindowAsync(isCancellable, navigationReason, true);