c# - Running a Method Upon Exit Button Click -
I have a C # / WPF application that has a main window and system tray icon when I close the main window To keep an application running in the system tray, configure App.xaml with Now I want to associate the main window on the "X" is a method of clicking on the close button, which checks to see if there is a member in the observation archive and to close the main window Does not allow, if calculation & gt; 0. I'm having trouble finding the method running when X button is clicked. Add a handler for the event, which you can close the window Called while attempting (including the X button). Then after your check, if you do not want to close the window, set your ShutdownMode = "OnExplicitShutdown" .
CancelEventArgs.Cancel to the correct.
Private Zero onWindow_Closing (Object Sender, CancelEventArgs E) {If (some collection.Count> 0) e.Cancel = true; }
Comments
Post a Comment