使用 Silverlight Prism 创建对话框
我是创建 Silverlight 应用程序的新手。我继承了一个代码库,我被告知正在使用 Prism。根据我在代码库中看到的内容,这看起来是正确的。我的问题是,我只是想打开一个对话框窗口并关闭一个对话框窗口。
要打开对话框窗口,我使用以下命令:
UserControl myDialog = new MyDialog();
IRegion region = myRegionManager.Regions["DIALOG_AREA"];
IRegionManager popupRegionManager = region.Add(myDialog, null, true);
region.Activate(myDialog);
出现我设计的对话框。它有两个按钮:“确定”和“取消”。当用户单击这些对话框时,我想关闭该对话框。我的问题是,我不知道该怎么做。因为对话框不是 ChildWindow,所以我无法调用 this.Close()。但是,当我将 MyDialog 更改为 ChildWindow 时,它被包裹在一些自定义窗口镶边中,我不知道如何摆脱它。
如何关闭 Prism 中的对话框?谢谢你!
I'm new to creating Silverlight applications. I have inherited a code-base that I've been told is using Prism. Based upon what I've seen in the code-base, this looks to be true. My problem is, I am just trying to open a dialog window and close a dialog window.
To open the dialog window, I'm using the following:
UserControl myDialog = new MyDialog();
IRegion region = myRegionManager.Regions["DIALOG_AREA"];
IRegionManager popupRegionManager = region.Add(myDialog, null, true);
region.Activate(myDialog);
The dialog I have designed appears. It has two buttons: "OK" and "Cancel". When a user clicks on of these dialogs, I want to close the dialog. My problem is, I have no idea how to do this. Because the dialog is not a ChildWindow, I cannot call this.Close(). But, when I change MyDialog to a ChildWindow, it is wrapped in some custom window chrome that i can't figure out how to get rid of.
How do I close a dialog in Prism? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该让 ViewModel 调用您调用对话框窗口的服务,而不是放置在不同的区域中。
记得使用 IOC 容器并在您的 ModuleClass 上声明:
我希望它有帮助。
如果您仍在寻找示例,请检查:
另一个 Stackoverflow 示例
Instead of putting in a different region, you should make your ViewModel call a service where you call your dialog window.
remember to use the IOC container and declare on your ModuleClass:
I hope it helps.
If you are still looking for an example, check:
another Stackoverflow sample