问题
I am using Caliburn.Micro.Core.2.0.1 on Windows Phone 8.1 (WinRT) application
All my ViewModels extends Screen
as the base.
In my MainView(Model)
I am able to navigate to a SettingsView(Model)
with CM's INavigationService using
private readonly INavigationService _navigationService;
public void Navigate()
{
_navigationService.NavigateToViewModel<SettingsViewModel>(_param);
}
Then using the Hardware Back Button or
public void GoBack()
{
_navigationService.GoBack();
}
I can navigate back to the MainView(Model).
It works; however, it does not work as I expected or wanted it to work.
When the GoBack (or Back button) is called, it generates a new instance of MainView(Model)
. I want it to return to the navigated from instance of MainView(Model)
.
I tried registering MainViewModel
as a Singleton, this makes the ViewModel
a singleton (and introduces some interesting issues); but the View
is still recreated.
Any idea how to get the navigation to go back to the navigated from instance?
回答1:
Try setting the NavigationCacheMode
property of your view to Enabled
.
For detailed information about this issue, please visit this blog post.
来源:https://stackoverflow.com/questions/27689706/caliburn-micro-goback-to-previous-page-instance-winrt