Caliburn Micro,来自单个视图模型的多个视图

发布于 2024-12-11 16:31:31 字数 277 浏览 0 评论 0原文

我目前正在开发一个应用程序,需要根据发生的事件更改视图。此事件意味着必须使用相同的 ViewModel 但使用不同的 View。我目前不知道 Caliburn 是否可以做到这一点,但我想应该可以。我遇到的主要问题是 Caliburn 的配置元素的约定。示例:

我有一个 ViewModel“MainViewModel”,它通过约定绑定到“MainView”。当事件发生时,我希望应用程序显示“MainView2”而不是“MainView”。我可以想象有一种编程方式可以设置它,但我对 Caliburn 的经验不足是一个问题。

I have an application that I am currently working on and there is a requirement to change the view based on an event occurring. This event means that the same ViewModel must be used but using a different View. I do not currently know if this is possible to do with Caliburn but I imagine it should be. the main problem I am having is the convention over configuration element of Caliburn. Example:

I have a ViewModel "MainViewModel" and it is bound to "MainView" through convention. When the event occurs I want the application to be displaying "MainView2" instead of "MainView". I can imagine there is a programmatic way of setting this but my inexperience with Caliburn is a problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨敛清荷 2024-12-18 16:31:31

您可以通过在显示视图的 ContentControl 上设置 cal:View.Context 属性来控制 ViewModel 使用哪个视图。

请查看此处

You can control which View is used for your ViewModel by setting cal:View.Context property on ContentControl that shows the view.

Have a look here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文