I need it for their own exit button. Tell me please? I try this: this.Close(); //or Exit dont work(
Microsoft continues to baby-step around the obvious, but it has officially deprecated the Universal Windows Platform (UWP) as it pushes the desktop-focused Windows App SDK (formerly called Project Reunion) and WinUI 3 as the future of Windows application development.
If the file location is the WindowsApps folder in Program Files, or Windows 10 refuses to open the folder, then it is a UWP App, because Win32 apps are stored in their own folder in Program Files (x86) and 64bit applications are stored in their own folder in Program Files . . . Power to the Developer!
Please run Windows Store Apps troubleshooter from Settings app > Update & security > Troubleshoot. See if it helps you. Hope this helps!
You can use the CoreApplication
class. It provides a static exit method:
public void CloseApp() { CoreApplication.Exit(); }
However, the documentation states the following:
Note Do not use this method to shut down an app outside of testing or debugging scenarios.
Sadly, the reason behind that is left unkown.
Further more, you can use the old-fashioned Application.Exit
method (non-static):
public void CloseApp() { Application.Current.Exit(); }
Here you should also take a look in the remarks:
Use this method to provide UI that enables users to exit your app. Normally, however, you should not provide this UI because the system automatically manages app lifetime and terminates suspended apps as needed to free resources.
tl;dr: Both Exit
methods will terminate the app, rather than suspending it. You should ask yourself if this really is the action you want to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With