private void NavigateBack(IEntityAwareViewViewModel vm) { ICancelAwareViewViewModel cancelAwareViewViewModel = vm as ICancelAwareViewViewModel; if (cancelAwareViewViewModel != null) { _regionManager.Regions[RegionNames.ContentRegion].RequestNavigate(cancelAwareViewViewModel.CancelNavigateToViewName); } else { INavigationAware navigationAwareVm = vm as INavigationAware; if (vm != null) { _regionManager.Regions[RegionNames.ContentRegion].NavigationService.Journal.GoBack(); } } }
public async void ExecuteCommand(IEntityAwareViewViewModel viewModel) { ValidatableBindableBase entity = viewModel.CurrentEntity; IDirtyAwareEntity dirtyAwareEntity = (entity as IDirtyAwareEntity); if (dirtyAwareEntity != null) { if (dirtyAwareEntity.IsDirty) { MessageDialogResult dialogResult; var mySettings = new MetroDialogSettings() { AffirmativeButtonText = "Yes, I want to cancel this action", NegativeButtonText = "No, I changed my mind", MaximumBodyHeight = 100, ColorScheme = MetroDialogColorScheme.Accented }; MetroWindow metroWindow = Application.Current.MainWindow as MetroWindow; dialogResult = await metroWindow.ShowMessageAsync("CONFIRM ACTION", "You are about to move away without saving. Are you sure you want to cancel the current action?", MessageDialogStyle.AffirmativeAndNegative, mySettings); if (dialogResult == MessageDialogResult.Affirmative) { NavigateBack(viewModel); } } else { NavigateBack(viewModel); } } else { NavigateBack(viewModel); } }