Hi @Nigel , Welcome to Microsoft Q&A.
Your idea is totally doable.
Just add it to the Closing event.
Then call the Hide()
method to hide the currently closed window//whatever you want to do.
public AboutWin()
{
InitializeComponent();
Closing += AboutWin_Closing; // Attach event handler
}
private void AboutWin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true; // Cancel the closing event
Hide(); // Hide the window instead of closing it
}
This method is fully applicable to Winfrom or Wpf.
If it does not work in WPF/Blazor, please comment bellow.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.