1. How to close the WPF program. The closure of the application is only possible if its shutdown method is called. There are three properties of shutdown. Onlastwindowclose,onmainwindowclose,onexplicitshutdown
1) by setting it directly in the App.xaml. Shutdown= "Onexplicitshutdown";
2) The second way: delete the App.xaml file, create a App.cs class yourself, in the Main method:
(Build Application object, build Win form object slightly)
App.shutdown=shutdownmodel. Onlastwindowclose;
App.run (Win);
2.Application also has many properties.
MainWindow Gets or sets the property
3. Add a Application event: Here are just two ways
On the App.xaml node, right-click on the property to find all of its properties and bind the event to the attribute you need. The result is as shown
This code will then appear in its App.xaml.cs file.
Then you need to change <page> to <applicationdefination> tag in this project file (*.csproj).
Two. The second approach is to implement the application event through the App.cs class
Win.show () displays the form.
App.run (Win) Startup form
App.exit+=application_exit; Delegate the application method to exit
void Application_exit (Objiect Sender,exiteventargs e) {}//The Exiteventargs here may differ depending on the event. Sender represents the object, and E represents some parameters for the event that is triggered.
WPF (Application How to create an event, and its application related properties)