问题描述
我在Windows Phone 8.1(WinRT)应用程序上使用Caliburn.Micro.Core.2.0.1
I am using Caliburn.Micro.Core.2.0.1 on Windows Phone 8.1 (WinRT) application
我的所有ViewModel扩展了 Screen
作为基础。
All my ViewModels extends Screen
as the base.
在我的 MainView(模型)
中,我可以导航到带有CM的INavigationService的 SettingsView(Model)
使用
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);
}
然后使用硬件后退按钮或
public void GoBack()
{
_navigationService.GoBack();
}
我可以导航回MainView(模型)。
I can navigate back to the MainView(Model).
有效;但是,它不能按我预期的那样工作或希望它能工作。
It works; however, it does not work as I expected or wanted it to work.
调用GoBack(或后退按钮)时,它会生成一个新实例的 MainView(模型)
。我希望它返回到 MainView(Model)
的从实例导航。
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)
.
我尝试将 MainViewModel
注册为单例,这使 ViewModel
成为单例(并引入了一些有趣的问题);但视图
仍会重新创建。
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?
推荐答案
尝试设置 NavigationCacheMode
您对 Enabled
启用的视图的属性。
Try setting the NavigationCacheMode
property of your view to Enabled
.
有关此问题的详细信息,请访问。
For detailed information about this issue, please visit this blog post.
这篇关于Caliburn Micro Go返回上一页实例WinRT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!