【问题标题】:Prism-MEF: how to navigate to view in different module using UriQueyPrism-MEF:如何使用 UriQuey 导航到不同模块中的视图
【发布时间】:2013-02-15 00:23:34
【问题描述】:

如果我有这个模块结构:

ModuleA
      *View/View_A
      *Controller/ControllerA
ModuleB
      *View/View_B
      *ViewModel/ViewModel_B  (view model for View_B)
      *Controller/Controller_B 
  1. ControllerA 如何使用 UriQuery 在区域中显示 View_B
    在 View_A 内

  2. controllerB 如何使用 UriQuery 在区域中显示 View_B 在 View_A 内

  3. 哪个更适合在 View_A 的区域中显示 View_B

提前致谢

【问题讨论】:

    标签: prism mef


    【解决方案1】:

    我不确定我是否准确回答了您的问题。但我建议你看一下 Prism2.2 附带的 Sample project -> Quickstarts -> UI Composition -> View Injection。这使用 Unity,示例在 Silverlight 和 WPF 中。

    这有如何显示来自不同模块的视图的示例。它不调用其他项目的控制器,而是调用presenter。

     IProjectsListPresenter projectsListPresenter = this.container.Resolve<IProjectsListPresenter>();
     projectsListPresenter.SetProjects(employee.EmployeeId);
    
     IRegionManager detailsRegionManager = detailsRegion.Add(detailsPresenter.View, employee.EmployeeId.ToString(CultureInfo.InvariantCulture), true);
     IRegion region = detailsRegionManager.Regions[RegionNames.TabRegion];
     region.Add(projectsListPresenter.View, "CurrentProjectsView");
     detailsRegion.Activate(detailsPresenter.View);
    

    使用 activate 方法来激活视图。或者,如果是特定要求/需要导航,您可以将 detailsRegionManager.RequestNavigate 与 UriQuery 一起使用。 (我还没有尝试请求导航自己:)

    另外请查看这篇文章

    http://compositewpf.codeplex.com/discussions/402860#post940396

    希望这会有所帮助。

    祝你好运!

    【讨论】:

    • 感谢您的帮助,但我使用的是 MEF,所以我使用视图导出而不是视图注入,我使用 UriQuery() 和 RequestNavigate 导航到位于另一个模块中的视图。可能是传递给uri的路径中的问题。
    • \Prism\Quickstarts\View-Switching Navigation\Silverlight\View-Switching Navigation 包含带有 MEF 和导航的示例。查看调用 ComposeEmailView 的 ContactsViewModel。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-25
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多