7

I've begun tinkering with making windows 8 apps And I want to make an exit button.

The problem is that Environment.Exit() and this.Close() that I'd use in winforms isn't in scope here.

anyone know how to close the app Programmatically?

Cœur
  • 37,241
  • 25
  • 195
  • 267

3 Answers3

8
Application.Current.Exit();

But closing a Metro app is not recommended. It is usually suspended.

tempid
  • 7,838
  • 28
  • 71
  • 101
5
Application.Exit

But be careful. You can fail certification by having code which forcefully closes the App. Make sure to read up on Certification Guidance if you plan to release to the store:

Your app must neither programmatically close nor offer UI affordances to close it. Windows 8 Process Lifetime Management closes Windows Store apps automatically.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
J. Tanner
  • 575
  • 2
  • 10
  • Microsoft has relaxed their guidance on this a bit on req 3.6 http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx#acr_changelog – Chris Ballance Mar 19 '15 at 20:03
2
Application.Current.Exit();

This was not allowed, but requirement 3.6, which used to not allow this, seems to be removed : http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx#acr_changelog