How to navigate to Windows Phone 8 start screen us

2019-09-06 00:33发布

问题:

I have built a very basic sound board app by following video tutorial series on channel 9 [http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners]. Each page in the app displays a list of sound tiles, which on tap plays associated sound. I have extended the app to allow user to tile the individual sound to phone's start screen. Everything works fine upto this point.

Now whenever user taps the sound from start screen, I want app tile to just play the sound, however its navigating into the application at the moment. I have raised similar question on channel 9 and the video series author suggested me that its possible by calling NavigationService.GoBack method on OnNavigatedTo event. I tried that, however I am getting exception with message 'Cannot go back when CanGoBack is false'. Here is the channel 9 thread - http://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-23-Testing-and-Submitting-to-the-Store

Appreciate if someone helps me to resolve the issue.

Entire source code of my app is available on GitHub at https://github.com/PrasadHonrao/WindowsPhone8/tree/master/SoundJabber

Thanks.

回答1:

To programmatically exit an application, you can call:

Application.Current.Terminate();

Unfortunately, it will work only on Windows Phone 8, this method isn't available on Windows Phone 7.



回答2:

You can't use navigationService.GoBack when you don't have navigation history. When you are in your main page and you want to exit your application you can use NavigationService.RemoveBackEntry() for remove navigation history.

If you want play sound for a specifique user.Create Model ou uri sound as parameter.

For information: when you use Application.Current.Terminate();.You don't pass in your app.cs.



回答3:

the simplest you can do is Application.Current.Terminate();