/// <summary> /// Process the given <see cref="NavigationResponse"/> instance /// </summary> /// <param name="response"></param> void INavigationHandler.ProcessResponse(NavigationResponse response) { // basic check if (response == null) { throw new ArgumentNullException("response"); } // we check if the navigation was successfull or not if (response.Status != ResponseStatus.Success) { this.PublishNavigationFailedInfo(response.Request); IShowMessageViewService showMessageService = ViewServiceLocator.GetViewService <IShowMessageViewService>(); showMessageService.ButtonSetup = DialogButton.Ok; showMessageService.Caption = "Chronos - Error en la navegaciĆ³n"; showMessageService.Text = ((response.Error != null) ? response.Error.Message : String.Format("No ha sido posible resolver la navegaciĆ³n solicitada ({0})", response.Request.RequestUrl)); showMessageService.ShowMessage(); } else { Application.Current.Dispatcher.BeginInvoke ( DispatcherPriority.Background, new ThreadStart ( () => { WindowElement window = response.Content as WindowElement; if (response.ResponseParameters != null && response.ResponseParameters.Count > 0) { ISupportNavigationLifecycle supporter = nRoute.Navigation.NavigationService.GetSupporter <ISupportNavigationLifecycle>(response.Content); if (supporter != null) { supporter.Initialize(response.ResponseParameters); } } this.PublishNavigatedInfo(window.Title, response); if (response.Request.NavigationMode == NavigateMode.Modal) { ServiceLocator.GetService <IVirtualDesktopManager>().ShowDialog(window); } else { ServiceLocator.GetService <IVirtualDesktopManager>().Show(window); } } ) ); } }
public static void ProcessNavigationLifecycle(NavigationRequest request, ISupportNavigationLifecycle supporter, ISupportNavigationViewLifecycle viewSupporter, Action <bool> supporterCallback, Action viewSupporterCallback) { // we check if our current page supports ISupportNavigation, if so we defer to it if (supporter != null) { supporter.Closing((b) => { supporterCallback(b); if (b) { if (viewSupporter != null) { viewSupporter.Closing(request, () => { viewSupporterCallback(); }); } else { viewSupporterCallback(); } } }); } else { supporterCallback(true); if (viewSupporter != null) { viewSupporter.Closing(request, () => { viewSupporterCallback(); }); } else { viewSupporterCallback(); } } }