Jeremy
Jeremy

Reputation: 179

MudBlazor: Prevent close when clicking outside dialog (on overlay)

Is it possible to prevent closing the MudBlazor dialog when clicking on the overlay (outside the dialog)? Or to run a Task when clicking on the overlay?

Upvotes: 2

Views: 2093

Answers (1)

fcd9
fcd9

Reputation: 167

To prevent closing the dialog when clicking on the overlay, you need to set DisableBackdropClick = true

For example:

@inject IDialogService DialogService

<MudButton OnClick="@((e) => OpenDialog())"
           Variant="Variant.Filled"
           Color="Color.Primary">Show Dialog</MudButton>

@code 
{
    private void OpenDialog()
    {   
        DialogOptions options = new DialogOptions() { DisableBackdropClick = true };
        DialogService.Show<DialogUsageExample_Dialog>("Custom Options", options);
    }
}

Upvotes: 8

Related Questions