How to display a Modal popup in a Blazor Server Application

1.5k Views Asked by At

I am creating a Blazor Desktop Application. For this I am using Blazor Server Application with ElectronNET.API. I have been trying to launch a modal popup upon clicking a button or a menu item. I tried using CreateWindowAsync(BrowserWindowOptions options, string loadUrl = "http://localhost"); method. Using this I am able to launch a window but it is not modal eventhough I have specified modal=true in the BrowserWindow options.

var windowOptions = new BrowserWindowOptions
                    {
                        AutoHideMenuBar = true,
                        AlwaysOnTop = true,
                        Type = "popup",
                        Width = 500,
                        Height = 300,
                        Center = true,
                        Modal = true,                       
                        Show = true
                    };

The Modal option has the comment that it will work only when the window is a child window but I don't know how to create a BrowserWindow as a child window without the Parent option. I specified the parent window with the BrowserWindow.SetParentWindow method after creating the BrowserWindow, but it didn't work modally.

It would be helpful if you could suggest a way to achieve modal popup in Blazor Desktop Application

0

There are 0 best solutions below