How to navigate to Windows Phone 8 start screen using C#

馋奶兔 提交于 2019-12-12 02:48:30

问题


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();



来源:https://stackoverflow.com/questions/18609609/how-to-navigate-to-windows-phone-8-start-screen-using-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!