Hi Kristóf,
Greetings from Syncfusion support.
We have validated your query “Blazor dialog automatically opens and cannot be closed.”
The dialog open can be prevented using the ‘Visible’ property. As it is a two-way binding property, it needs to be used as “@bind-Visible” and set to false to prevent the opening of the dialog.
And the dialog can be closed using the close icon by enabling the “ShowCloseIcon” property to true. Also, the dialog can be closed by clicking outside the dialog. For this first enable the “IsModal” property to true and then the “@bind-Visible” property can be set as false in the “OnOverlayClick” event. We have modified the shared sample for your reference,
Code Snippet:
|
<SfDialog Width="1000px" @bind-Visible="@IsOpen" IsModal="true" ShowCloseIcon="true" >
<DialogEvents OnOverlayClick=@OnOverlayclick />
<DialogTemplates>
<Header>
<h3>@Title</h3>
</Header>
<Content>
@ChildContent
</Content>
</DialogTemplates>
</SfDialog>
@code
{
[Parameter]
public bool IsOpen { get; set; } = false;
private void OnOverlayclick()
{
this.IsOpen = false;
}
} |
Please check the above code snippet and the sample and let us know if it satisfies your requirement.
Regards,
Revanth