mudblazor

How to open dialog in modal fashion?


I am trying to open a dialog in mudblazor, but it seems the execution does not wait for it to close. In this case, the computer will beep while the dialog is still open. Why?

razor:

@inject IDialogService Dialog

code behind:

private async Task ChangeAvatar()
{
    var result = await Dialog.ShowAsync<DlgAvatarSelection>("Select avatar",
        new DialogOptions { CloseButton = true, CloseOnEscapeKey = true });
    Console.Beep(1000, 25);
}

Solution

  • Found it, I have to use Show and await the results Result.

    var dlg = Dialog.Show<DlgAvatarSelection>("Select avatar");
    var result = await dlg.Result;
    var data = result.Data;