Caliburn Micro GoBack to previous page instance WinRT

柔情痞子 提交于 2019-12-23 03:46:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!