mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
How to prevent electron window closing when click close and ask confirmation #666
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @soundararajans on GitHub (May 13, 2021).
Originally assigned to: @GregorBiswanger on GitHub.
How to prevent electron window closing when click close and ask confirmation
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;
`
@NepPure commented on GitHub (Aug 19, 2021):
The same question
@GregorBiswanger commented on GitHub (Mar 28, 2023):
🎉🚀 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!