使用 PRISM,如何显示另一个模块的视图,并访问其属性以更新其状态?
我有两个模块,一个是标题模块,一个是项目模块。
我有一个 HeaderDetails 视图,其中包含一个名为“ItemsSummaryRegion”的区域。该区域注册为使用 Items 模块中的视图 ItemListView 填充该区域。
regionManager.RegisterViewWithRegion("ItemsSummaryRegion", typeof(IItemListView));
问题是,我如何访问这个自动生成的视图,以便我可以设置它应该显示的项目列表?我想在 HeaderDetails 视图的 ViewModel 中设置它。
有谁知道你是怎么做到的?或者可以建议一种更好的方式来显示这些数据?
谢谢。
I have two modules, one is a Header module, one is a Items module.
I have a HeaderDetails view, which contains a region which is called 'ItemsSummaryRegion'. This region is registered to populate the region with the view ItemListView from the Items module.
regionManager.RegisterViewWithRegion("ItemsSummaryRegion", typeof(IItemListView));
The issue is, how do I get access to this automatically generated view so that I may set the list of Items it is supposed to display? I want to set this in the ViewModel of the HeaderDetails view.
Does anyone know how you do this? Or can suggest a better way of displaying this data?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的两个模块如此紧密地耦合,那么只有一个模块包含两个视图并使用主/详细信息设置它们不是更有意义吗?
此示例显示了与您想要实现的目标类似的内容:
http://www.tanguay.info/web/index.html php?pg=codeExamples&id=105
If your two modules are so tightly coupled, wouldn't it make more sense to have just one module containing both views, and to set them up with master/detail.
This example shows something similar of what you are trying to achieve:
http://www.tanguay.info/web/index.php?pg=codeExamples&id=105
您应该使用 unityContainer 创建事物,然后调用 Add 和 Activate。
这允许您稍后在想要清除该区域时调用
IRegion.Remove
。如果您只想向视图注册一个区域,您也可以这样做,只需将我的逻辑的最后几行替换为对 RegisterViewWithRegion 的其他调用:You should use the unityContainer to create things and then call Add and Activate.
This allows you to call
IRegion.Remove
later when you want to clear the region. If you just want to register a region with a view, you can do that too, just replace the last couple lines of my logic with the other call to RegisterViewWithRegion: