Silverlight 4 和 Prism 中的弹出窗口
在 Silverlight 和 PRISM 中,通过从不同模块中的 ViewModel 传递参数来打开一个模块中的弹出子窗口的好方法是什么。
In Silverlight and PRISM, what is the good way to open a popup child window which is in one Module by passing a parameter from a ViewModel in different Module.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
创建两个模块都知道的公共接口/类,称为 IChildWindowService,在引导程序中注册 IChildWindowServe/ChildWindowService。
创建一个公共的 CompositePresentationEvent,该事件会将参数从 a 点传递到 b 点
public class OpenChildWindowWithParameters : CompositePresentationEvent{}
模块 A 中的 ViewModel 引发该事件。
模块 B 中的控制器注册事件并对事件做出反应。
模块B中的控制器将子窗口服务作为依赖项。
当事件发生时,控制器将在模块 B 中创建 VM 并将参数传递给它,从事件中,它还将使用服务来显示子窗口。
Create a common interface/class known to both module, called IChildWindowService, register the IChildWindowServe/ChildWindowService in the bootstrapper.
Create a common CompositePresentationEvent, this event will pass the parameters from point a to point b
public class OpenChildWindowWithParameters : CompositePresentationEvent<ParamEventArgs>{}
The ViewModel in Module A raises the Event.
The Controller in Module B registers and reacts to the Event.
The Controller in Module B takes the child window service as a dependency.
When the event is raised the Controller will create the VM in Module B and pass the parameters to it, from the event, it will also use the Service to display a ChildWindow.