this.Frame.Navigate(typeof(SomeClass), file);
this.Frame.GoBack();
Hello guys,
Goback() method is creating a new instance, but i do not want it.I want the previous page stay how i left, and keeps data. Any idea about that issue?
this.Frame.Navigate(typeof(SomeClass), file);
this.Frame.GoBack();
Hello guys,
Goback() method is creating a new instance, but i do not want it.I want the previous page stay how i left, and keeps data. Any idea about that issue?
You have to set the NavigationCacheMode property:
public MainPage()
{
InitializeComponent();
NavigationCacheMode = NavigationCacheMode.Enabled;
}
In App.xaml.cs you should be setting the size of the frame's page cache. Add the line that sets the CacheSize after the NavigationFailed handler is assigned.
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
// Add this line after the above 2 lines that already exist.
rootFrame.CacheSize = 2; // Or some other number that makes sense for your application
On the page where you want to retain data, in the XAML set the cache mode to required.
<Page ... NavigationCacheMode="Required" >...</Page>
In your codebehind, you may need to override OnNavigatedFrom and OnNavigatedTo to save and restore state.
If you do not want to retain data, set NavigationCacheMode="Disabled" on that page. You still navigate using Frame.Navigate(typeof(SomePage));
you can serialize all your data of your viewmodel or class and restore or save the data to recover the previous information.
here is an example.