Caliburn Micro,来自单个视图模型的多个视图
我目前正在开发一个应用程序,需要根据发生的事件更改视图。此事件意味着必须使用相同的 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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过在显示视图的 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.