Beispiel #1
0
        private async void ShowAddPluginDialog(object sender, RoutedEventArgs e)
        {
            BaseMetroDialog dialog = (BaseMetroDialog)this.Resources["AddPluginDialog"];

            dialog.DataContext = new AddAssemblyModel();
            await this.ShowMetroDialogAsync(dialog);

            await dialog.WaitUntilUnloadedAsync();
        }
Beispiel #2
0
    /// <summary>
    /// Tweak around mahapps' behaviour with dialogs - Unloaded fires when showing child dialogs as well as when hiding dialog itself.
    /// We need to wait til dialog itself is close.
    /// </summary>
    /// <param name="dialog">Dialog to show.</param>
    /// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
    public virtual async Task ShowAndWaitForClosedAsync(BaseMetroDialog dialog)
    => await Application.Current.Dispatcher.Invoke(async() =>
    {
        // Remember where we were before showing.
        BaseMetroDialog parentDialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel);

        await dialogCoordinator.ShowMetroDialogAsync(viewModel, dialog);

        BaseMetroDialog currentDialog;
        do
        {
            // Wailt until unload of this dialog (may happen multiple times)
            await dialog.WaitUntilUnloadedAsync();

            // Check if current dialog is the one that we remembered
            currentDialog = await dialogCoordinator.GetCurrentDialogAsync <BaseMetroDialog>(viewModel);
        }while (currentDialog != parentDialog);
    });