Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a Windows Phone 8.1 app

In WP7 and WP8 I just needed to clear the backstack in a page, then press Back button and the app is closed. In WP8.1 I do Frame.BackStack.Clear(), press Back and the app just minimizes.. How to kill it with Back button?

like image 830
v.g. Avatar asked Sep 02 '14 14:09

v.g.


People also ask

How do I close a Windows 8 app?

Press Ctrl + Alt + Del on your keyboard to bring up the Windows logon screen. Select Task Manager. Under the Processes tab, locate the app you'd like to close. Right-click the app and select End Task from the drop-down menu that appears.

Does Windows Phone 8.1 still work?

Will my phone still work after July 11, 2017? Yes. Your Windows Phone 8.1 device should continue to work after July 11, 2017, but there will be no updates after July 11, 2017 (including security updates) and device backup functionality and other backend services will be phased out as described above.


2 Answers

You can add, in your main page definition:

Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;

Then

private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
    if (!e.Handled && Frame.CurrentSourcePageType.FullName == "YourApp.MainPage")
        Application.Current.Exit();
}

Warning: As others said, you should not use this and let the system handle the app closure. For example, if you use the Application Insights, I found that they are not sent to Azure when in Release mode

like image 100
the_nuts Avatar answered Oct 12 '22 12:10

the_nuts


I think the above has been depreceated. Exit is now an event.

Try

Application.Current.Terminate();

like image 36
MattyMerrix Avatar answered Oct 12 '22 12:10

MattyMerrix