Close Button on VS11 Apps

2019-02-18 01:31发布

问题:

I try to create an Application on Windows 8 with VS 11 with C#, And I need to a Button in my App that when people Click on this button , my App going to Close.

But I can't find any Exit or Close function to add, to my Click Event.

how can I make this button? or what is your proposal to solving this Problem?

回答1:

If you don't care about certification - e.g. you want a close button in your own debug build to help you with testing - you can call Application.Current.Exit()



回答2:

You shouldn't close your app.

This is one of the concepts of Metro apps.The user switches to a different task and the Process Lifetime Management aspects kick in, first suspending your application and then later, if needed, terminating it. Don't close the application's window: let the user know that there is no information currently available and then let them switch away, close, or wait as they'd prefer.

Took from here



回答3:

You must not implement Close Button.

If you do so, your app will be not able to sell in the store. See "Certification requirements for Windows apps".

3.6 Your app must use the mechanisms provided by the system for those features that have them
(snip)
Your app must neither programmatically close nor offer UI affordances to close it.



回答4:

You want this? App.Current.Exit();



回答5:

Try this.. It worked

App.Current.Terminate();