使用 PRISM,如何显示另一个模块的视图,并访问其属性以更新其状态?

发布于 2024-08-23 06:11:16 字数 380 浏览 4 评论 0原文

我有两个模块,一个是标题模块,一个是项目模块。

我有一个 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 技术交流群。

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

发布评论

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

评论(2

情绪操控生活 2024-08-30 06:11:16

如果您的两个模块如此紧密地耦合,那么只有一个模块包含两个视图并使用主/详细信息设置它们不是更有意义吗?

此示例显示了与您想要实现的目标类似的内容:
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

我不咬妳我踢妳 2024-08-30 06:11:16

您应该使用 unityContainer 创建事物,然后调用 Add 和 Activate。

    public TaskList(IEventAggregator eventAggregator, 
                    IRegionManager regionManager, 
                    IUnityContainer container)
    {
        _EventAggregator = eventAggregator;
        _RegionManager = regionManager;
        _Container = container;
    }


        IItemListVM vm = _Container.Resolve<IItemListVM>();
        IItemListView view = new IItemListView(vm);

        _RegionManager.Regions["ItemsSummaryRegion"].Add(view);
        _RegionManager.Regions["ItemsSummaryRegion"].Activate(view);

这允许您稍后在想要清除该区域时调用IRegion.Remove。如果您只想向视图注册一个区域,您也可以这样做,只需将我的逻辑的最后几行替换为对 RegisterViewWithRegion 的其他调用:

_RegionManager.RegisterViewWithRegion("ItemsSummaryRegion", 
     (x) => 
     { 
          _Container.Resolve<IItemListView>(); 
     });

You should use the unityContainer to create things and then call Add and Activate.

    public TaskList(IEventAggregator eventAggregator, 
                    IRegionManager regionManager, 
                    IUnityContainer container)
    {
        _EventAggregator = eventAggregator;
        _RegionManager = regionManager;
        _Container = container;
    }


        IItemListVM vm = _Container.Resolve<IItemListVM>();
        IItemListView view = new IItemListView(vm);

        _RegionManager.Regions["ItemsSummaryRegion"].Add(view);
        _RegionManager.Regions["ItemsSummaryRegion"].Activate(view);

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:

_RegionManager.RegisterViewWithRegion("ItemsSummaryRegion", 
     (x) => 
     { 
          _Container.Resolve<IItemListView>(); 
     });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文