prism wpf:如何在一个区域中显示视图/模块

发布于 2024-09-27 06:11:08 字数 282 浏览 0 评论 0原文

我有一个包含一个区域的 Shell 类。我创建了一个模块,例如显示办公室列表。当我选择一个办公室时,我想显示另一个模块,我想在其中传输有关所选办公室的信息。 问题:

  • 什么更好:创建另一个模块或在现有视图中创建另一个视图?
  • (如果我仍然想创建第二个模块),我必须如何更改区域中的视图?请注意,我只有一个区域,因此我需要隐藏第一个模块的视图或卸载它。
  • 如果我想在 shell 中再添加一个区域怎么办?例如,每个模块必须包含 2 个视图并更改所有视图。

谢谢。

I have a Shell class with one region. I created a module which shows,for example, a list of offices. When I choose one of offices I want to show another module where I want to transfer information about chosen office.
Questions:

  • what is better: to create another module or maybe to create just another view in existing?
  • (if I still want to create second module), how do I must to change views in region? Notice, I have only one region, so I need either hide view of first module or unload it.
  • What if I want to add one more region to shell? E.g. every module must contains 2 views and change all of them.

Thanks.

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

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

发布评论

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

评论(1

弃爱 2024-10-04 06:11:08

我将尝试分别回答这些问题。

  1. 如果您要显示的信息与列表视图的信息相关(例如特定办公室的详细信息),则常见的方法是在同一模块中创建另一个视图。这是因为这两种视图都与办公室相关并共享相关的关注点,因此为它们提供单独的模块带来的痛苦多于收益。
  2. 无论您是否决定创建第二个模块,如果您只想在 Shell 中拥有一个区域并一次仅显示一个视图,则必须使用 ContentControl 作为区域的宿主,它充当 SingleActiveRegion
  3. 如果要向 Shell 添加更多区域,只需添加更多控件并使用区域的 RegionManager 依赖属性标记它们即可。许多 Prism 快速入门都表明了这一点。要在模块之间进行通信,只需使用 EventAggregator

我希望这有帮助。

I'll try to answer the questions separately.

  1. If the information you are going to show is related to that of the list view (say the details of a particular office), the common approach would be creating another view in the same module. This is because both views are related to offices and share related concerns, so having a separate module for them brings more pain than gain.
  2. Whether you do decide to create a second module or not, if you want to only have a sinlge region in the Shell and display only a view at a time, you must use as a Region's host a ContentControl, which acts as a SingleActiveRegion.
  3. If you want to add more regions to the Shell, just add more controls and mark them with the RegionManager dependency property for regions. Many of the Prism quickstarts show this. To communicate between modules just use the EventAggregator.

I hope this helps.

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