---
title: "Windows Phone 8.1 Universal App terminates on navigating back from second page?"  
description: "Windows Phone 8.1 Universal App terminates on navigating back from second page?"  
author: "Anonymous User"  
published: 2015-04-24  
updated: 2015-04-24  
canonical: https://www.mindstick.com/forum/23130/windows-phone-8-1-universal-app-terminates-on-navigating-back-from-second-page  
category: "windows phone"  
tags: ["windows phone"]  
reading_time: 2 minutes  

---

# Windows Phone 8.1 Universal App terminates on navigating back from second page?

I have 2 pages in my [Windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) [Phone](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) 8.1 [Universal](https://answers.mindstick.com/qa/101376/who-s-the-current-wwe-universal-champion) App.I navigate from Page1.xaml to Page2.xaml by using a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) with the [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event) code:this.Frame.Navigate(typeof(Page2));When I am on Page2, and I use the [hardware](https://www.mindstick.com/blog/303100/best-pc-hardware-2023) back button the app closes without an [exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) or anything. It just returns to the startscreen.

I [already](https://yourviews.mindstick.com/view/88453/the-hidden-ways-ai-is-already-controlling-your-daily-life) tried the following on Page 2:

```
public Page2()    {        this.InitializeComponent();        Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;    }    void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)    {        Frame.GoBack();    }
```

\

As far as I know I do not clear the back stack.

What is going on, and how can I fix this?

## Replies

### Reply by Anonymous User

This is new to Windows Phone 8.1.\
If you create a new Hub Universal App using a VS2013 template, you'll notice a class in Common folder called a NavigationHelper.\
This NavigationHelper gives you a hint how to properly react to back button press. So, if you don't want to use the NavigationHelper, here's how to get the old behavior back:

```
public BlankPage1(){    this.InitializeComponent();    HardwareButtons.BackPressed += HardwareButtons_BackPressed;}void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e){    if (Frame.CanGoBack)    {        e.Handled = true;        Frame.GoBack();    }}
```

\
You can also do it on app level, to avoid having to do it on every page:\
\

```
public App(){    this.InitializeComponent();    this.Suspending += this.OnSuspending;    #if WINDOWS_PHONE_APP    HardwareButtons.BackPressed += HardwareButtons_BackPressed;    #endif}#if WINDOWS_PHONE_APPvoid HardwareButtons_BackPressed(object sender, BackPressedEventArgs e){    Frame rootFrame = Window.Current.Content as Frame;    if (rootFrame != null && rootFrame.CanGoBack)    {        e.Handled = true;        rootFrame.GoBack();    }}#endif
```


---

Original Source: https://www.mindstick.com/forum/23130/windows-phone-8-1-universal-app-terminates-on-navigating-back-from-second-page

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
