开发者

Windows phone Navigation issue

I have an application where from the MainPag开发者_如何学Pythone.xaml I navigate to a page called say two.xaml.

In Two.xaml I then navigate to Three.xaml..

Now for Three.xaml I want to navigate back to the mainPage.Xaml.

In Three.xaml if I do

this.NavigationService.GoBack();
this.NavigationService.GoBack();

I get an InvalidOperationException.

If I do

NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));

the system will crate another instance of MainPage.xaml, which I do not want as it will lose its original state.

Anyone have solutions to this issue?


you can save the actual state for example in the State-Property of the PhoneApplicationService Class, then Navigate through your pages and when getting back to the MainPage you just implement the OnNavigatedTo()-method of the MainPage and load the State-Data.

Hope this helps...


AFAIK, you are not supposed to manipulating the back stack in your app. What cordellcp3 says may be a good idea to implement


If your intent is to navigate in this way: MainPage->PageTwo->PageThree User presses Back Button and goes to MainPage you can use this: NavigationService.RemoveBackEntry() documentation

hope it helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜