Electron.NET
Electron.NET copied to clipboard
How to prevent electron window closing when click close and ask confirmation
How to prevent electron window closing when click close and ask confirmation
- Node Version: V 14.17.0
- Electron.Net Nuget: 11.5.1
- Target: Win
- .Net: Net5.0
I tried the below code. But it's not working and window is closing always without asking confirmation.
`
window.OnClose += () =>
{
MessageBoxOptions options = new MessageBoxOptions("Changes you made may not be saved");
options.Type = MessageBoxType.question;
options.Buttons = new string[] { "No", "Yes" };
options.DefaultId = 1;
options.CancelId = 0;
if (Electron.Dialog.ShowMessageBoxAsync(options).Result.Response == 1)
{
}
};
`
The same question
🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉
With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!