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 #664
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;
`