Caliburn.Micro(UWP):如何制作向导?

Caliburn.Micro(UWP):如何制作向导?,uwp,caliburn.micro,Uwp,Caliburn.micro,使用Caliburn.Micro(UWP),我制作了一个向导页面来设置一些东西 什么是向导? 向导的意思是,先显示第1页,以后再输入。如果一切顺利, 接下来,我们将显示第2页、第3页。。。。。并启动应用程序 与此图像类似,ShellViewModel是基于视图的模型。本课程中,我们称之为: ActivateItem(Page_1_ViewModel); ActivateItem(Page_2_ViewModel); ActivateItem(Page_3_ViewModel); 每一页都有逻

使用Caliburn.Micro(UWP),我制作了一个向导页面来设置一些东西

什么是向导? 向导的意思是,先显示第1页,以后再输入。如果一切顺利, 接下来,我们将显示第2页、第3页。。。。。并启动应用程序

与此图像类似,ShellViewModel是基于视图的模型。本课程中,我们称之为:

ActivateItem(Page_1_ViewModel);
ActivateItem(Page_2_ViewModel);
ActivateItem(Page_3_ViewModel);
每一页都有逻辑来决定我们是可以进入下一页还是留下来。我们不会将此逻辑放在ShellViewModel上

问题 有没有切换页面的好方法?我想从每个页面调用一些东西来打开ShellViewModel。难点是每一页都在shell上。我们不能从每个页面调用Shell上的任何内容。(你能理解吗?)

这是我的路。 若你们有更好的方法,请分享想法

我的计划是使用EventAggregator。从每个页面,我们发布一个事件,以命令“Shell”切换页面

await _eventAggregator.PublishOnUIThreadAsync(new BaseScreenSwitchMessage(typeof(Page_2_ViewModel)));
public void Handle(BaseScreenSwitchMessage message)
    {
        ActivateItem(Activator.CreateInstance(message.NextScreenType));
    }
下面是事件消息类

public class BaseScreenSwitchMessage
{
    public BaseScreenSwitchMessage(Type _nextScreenType)
    {
        NextScreenType = _nextScreenType;
    }

    public Type NextScreenType { get; }
}
并且每页都可以命令“Shell”切换页面

await _eventAggregator.PublishOnUIThreadAsync(new BaseScreenSwitchMessage(typeof(Page_2_ViewModel)));
public void Handle(BaseScreenSwitchMessage message)
    {
        ActivateItem(Activator.CreateInstance(message.NextScreenType));
    }
ShellViewModel使用此方法切换页面

await _eventAggregator.PublishOnUIThreadAsync(new BaseScreenSwitchMessage(typeof(Page_2_ViewModel)));
public void Handle(BaseScreenSwitchMessage message)
    {
        ActivateItem(Activator.CreateInstance(message.NextScreenType));
    }
有什么好办法吗?


至少,上述方法效果良好。我可以切换页面1->2->3…

以上切换页面的方式是否存在任何问题?如果没有,您似乎可以使用它。从Page_1到ShellViewModel,没有EventAggregator,有没有办法告诉您订单?冒泡?上述切换页面的方式是否存在任何问题?如果没有,您似乎可以使用它。从Page_1到ShellViewModel,没有EventAggregator,有没有办法告诉您订单?冒泡?