Reputation: 2668
I'm building an application for Windows 8 and need to be able to close it programmatically using an action. For example, a button on my application.
I'm building my application using HTML5
Upvotes: 2
Views: 2579
Reputation: 1454
The following event handler worked for me...I actually put an Exit icon in a global app bar...users love it!
private void closeButton_Click(object sender, RoutedEventArgs e)
{
App.Current.Exit();
}
Good Luck!
This solution above works for C#...it's especially helpful when using Windows 8 Store Apps on machines that are not touch screen capable (our users were having difficulty emulating the top down swipe to close an app...other users are running a Windows 8 on a Mac VM which makes the Alt + F4 tough)
Upvotes: 9
Reputation: 1182
You can't close an app programmatically, it's the system's choice.
Upvotes: 1
Reputation: 16142
You cannot. The Windows Runtime API (and the modern subset of the windows SDK) don't provide mechanisms to terminate applications.
The model for Windows Runtime based applications is to allow the system or the user to manage the process lifetime.
Upvotes: 3