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 ShutdownMode = "OnExplicitShutdown" .

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 CancelEventArgs.Cancel to the correct.

  Private Zero onWindow_Closing (Object Sender, CancelEventArgs E) {If (some collection.Count> 0) e.Cancel = true; }    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -