Skip to content
Nuvyntra Labs

Documentation

Dialogs

IDialogs via MessageBox and INotifier toast on AdornerLayer — never wrapping Window.Content.

Dialogs

Add Plugin.Wpf.MVVMExpress.Dialogs and call UseDialogs() on UseWpfMvvmExpress. Inject IDialogs for alerts/confirm and INotifier for toast. WpfDialogs hops to IMainThread like WpfNotifier. WpfToastPresenter draws on AdornerLayer — it never wraps or replaces Window.Content, so ResetAsync cannot restore a stale tree. Wrap MainWindow content in AdornerDecorator. Tests use FakeDialogs.

public sealed class ProductEditViewModel : PageViewModel
{
    public ProductEditViewModel(IDialogs dialogs, INotifier notifier)
        : base(navigator: null, dialogs)
    {
    }

    public async Task DeleteAsync(CancellationToken cancellationToken)
    {
        var ok = await Dialogs!.ConfirmAsync(
            "Delete product",
            "This cannot be undone.",
            accept: "Delete",
            cancel: "Cancel",
            cancellationToken);

        if (!ok)
        {
            return;
        }

        await _catalog.DeleteAsync(_productId, cancellationToken);
        await Notifier.ToastAsync("Deleted", cancellationToken: cancellationToken);
    }
}

Discussion

Comment on Plugin.Wpf.MVVMExpress. The thread lives on this component's GitHub repository (nuvyntralabs/Plugin.Wpf.MVVMExpress). Sign in with GitHub — Giscus uses Discussions, Utterances uses Issues.