[英]Caliburn.Micro and app resume
In my Windows Phone Silverlight 8.1 app I enabled the app resume (ActivationPolicy="Resume") 在我的Windows Phone Silverlight 8.1应用程序中,我启用了应用程序履历表(ActivationPolicy =“ Resume”)
When the user re-open the app (using the main tile), the OnDeactivate method of the ViewModel is called after the OnActivation method. 当用户重新打开应用程序(使用主磁贴)时,将在OnActivation方法之后调用ViewModel的OnDeactivate方法。
Is it correct? 这是正确的吗? How can I handle the app resume with Caliburn.Micro?
如何使用Caliburn.Micro处理应用程序简历?
Here is the code of the ViewModel: 这是ViewModel的代码:
public class Page2ViewModel: Screen
{
protected override void OnActivate()
{
base.OnActivate();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
}
}
This does not seem right. 这似乎不正确。
OnDeactivate
is called when navigating away from a View. 从视图导航时,将调用
OnDeactivate
。 In your ViewModel there is no way to directly differentiate if it was activated from normal navigation or because of resuming. 在ViewModel中,无法直接区分是从正常导航中激活还是由于恢复而被激活。
Take a look at your Bootstrapper, you can override OnActivate
and OnLaunch
methods there that correspond to Application_Launching
and Application_Activated
. 看一下Bootstrapper,您可以重写与
Application_Launching
和Application_Activated
相对应的OnActivate
和OnLaunch
方法。 OnActivate
is the one you want. OnActivate
是您想要的一种。
The problem was in the AppBootstrapper
. 问题出在
AppBootstrapper
。
To handle the app fast resume, the Navigated
and Navigating
events must be subscribed in the CreatePhoneApplicationFrame
frame. 要处理应用程序的快速恢复,必须在
CreatePhoneApplicationFrame
框架中订阅Navigated
和Navigating
事件。
In this repository the fix (see commit list for the history). 在此存储库中的修复程序(有关历史记录,请参见提交列表)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.