Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I create a Universal apps. in Windows 8.1 Project i have 2 Pages.
when i changed anything in the MainPage and press the GoForward button like this code>

Frame.Navigate(typeof(Page2));

everything is working, but in the Page 2 i have a GoBack button when i pressed that button by this code:

MainPage.Current.GoBack();

everything in the MainPage i'v changed will be gone (like a fresh start).
how can i solve this problem?
Posted
Comments
LLLLGGGG 12-Jan-15 14:37pm    
Hi,

Try Frame.GoBack();
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.frame.goback

Hope this helps...
LG

1 solution

As far as I know, in Windows 8 application programming, the MainPage is a name given to the default page of the application, and the Page object doesn't contain the definition for Current, did you try to use it for Window.Current like thing? So the error is there, where did that property come from? Have a look at the Page[^] class and see for yourself.

However, the navigation works for the Frames of the page. Where you change the content of the Frame object.

Application life cycle documentation[^]. One more thing that I recall while learning this navigation 2 days ago, was that you need to enable the NavigationCacheMode property of the page. Which will enable you to reserve the data of your page, inside the memory and upon loading the page would be loaded from the memory and not as a new page.

So you're required to use the Frame.Navigate(typeof(YourPage)); possibly the Frame would be replaced by the frame object of your page, if you're using the default code (code that Visual Studio generated) then it is written as rootFrame.
 
Share this answer
 
Comments
RMTJJ 13-Jan-15 5:48am    
Hi, the Current object is in MainPage i'v wrote>
public sealed partial class MainPage : Page
{
public static MainPage Current;
public MainPage()
{
this.InitializeComponent();
Current = this;
}

-----

thank you for your solution, the problem was i haven't enabled the NavigationCacheMode.
thanks alot Ahmad.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900