/// <summary> /// метод расширения для IViewModel, отображающий заставку /// </summary> /// <param name="iViewModel">расширяемый тип</param> /// <param name="pageToShow">отображаемая заставка</param> /// <param name="milliseconds">время показа заставки</param> /// /// <param name="pageToChange">страница, которая загрузится после заставки</param> public static async void ChangePageWithDialog(this IViewModel iViewModel, IViewModel pageToShow, int milliseconds, IViewModel pageToChange = null) { ServiceLocator.Default.ResolveType <IUIVisualizerService>().Show(pageToShow); Thread.Sleep(milliseconds); // если нужно - переходим на другую страницу if (pageToChange != null) { ((MainWindowViewModel)iViewModel).ChangeCurrentPage(pageToChange); } await pageToShow.CloseViewModelAsync(true); }
/// <summary> /// Cancels the editing of the data, but also closes the view model in the same call. /// </summary> /// <returns><c>true</c> if successful; otherwise <c>false</c>.</returns> public static async Task <bool> CancelAndCloseViewModelAsync(this IViewModel viewModel) { Argument.IsNotNull("viewModel", viewModel); var result = await viewModel.CancelViewModelAsync(); if (result) { await viewModel.CloseViewModelAsync(false); } return(result); }
/// <summary> /// Cancels the editing of the data, but also closes the view model in the same call. /// </summary> /// <returns><c>true</c> if successful; otherwise <c>false</c>.</returns> public static async Task <bool> CancelAndCloseViewModelAsync(this IViewModel viewModel) { Argument.IsNotNull("viewModel", viewModel); var viewModelBase = viewModel as ViewModelBase; if (viewModelBase != null) { var exitAfterBlock = false; if (viewModelBase.IsCanceling) { exitAfterBlock = true; if (!await viewModelBase.AwaitCancelingAsync()) { return(false); } } if (viewModelBase.IsClosing) { exitAfterBlock = true; await viewModelBase.AwaitClosingAsync(); } if (exitAfterBlock) { return(true); } } var result = await viewModel.CancelViewModelAsync(); if (result) { await viewModel.CloseViewModelAsync(false); } return(result); }
private async void OnExitCommandExecute() { await _parentViewModel.CloseViewModelAsync(true); }