3
votes

I made a simple Windows 8 quiz game.

I have 3 pages: MainPage, GamePage and ScorePage

The GamePage has a timer so I have to answer as many questions in 30 seconds as I can. It also has a Back button in case I want to give up and a Retry button to start over.

The problem is that whenever I click the Back or Retry button, the new page is displayed correctly but the old GamePage still works in the background and when the time is up it will display the ScorePage

For example I open the app, start the game and click Back. After the time is up, even if I closed the game (or so i thought), the ScorePage will still be displayed...

So how can I completely dispose of that instance of the page?

It is the first time I tried to make a W8 App, I only used WinForms before, where I used this.Close(); to completely get rid of the pages/forms.

To open pages I used this.Frame.Navigate(typeof(GamePage), null); and this.Frame.Navigate(typeof(ScorePage), new int[] { Correct, Wrong });

1

1 Answers

0
votes

The below code remove back entries from the stack

 if (NavigationService.CanGoBack)
    {
        while (NavigationService.RemoveBackEntry() != null)
        {
            NavigationService.RemoveBackEntry();
        }
    }

You can close the app this way

Application.Current.Terminate();