WPF + PRISM - 显示带有控件的模式弹出窗口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11812569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF + PRISM - show modal popup window with controls in it?
提问by John Miner
I am following the 'Stock Trader RI'example by the Prism team, but it does not address this exactly :
我正在关注Prism 团队的“Stock Trader RI”示例,但它并没有完全解决这个问题:
I have a Shellwith a Main Regionin it.
我有一个带有主要区域的外壳。
In this shell I have some filter fields and a grid.
在这个 shell 中,我有一些过滤器字段和一个网格。
When I press on a button - I would like to load a screen that allows me to change the filters,
当我按下按钮时 - 我想加载一个允许我更改过滤器的屏幕,
and then press 'Save'. This would then call a service to update the fields, and close the pop-up.
然后按“保存”。这将调用服务来更新字段,并关闭弹出窗口。
Here is an illustration of the 'Shell' before pressing the button (left) and after (right) :
这是按下按钮之前(左)和按下按钮之后(右)的“外壳”图示:
Problems are :
问题是:
- The 'Stock Trader RI' sample app only uses a modaless dialog popup. I need a MODALpop-up (background will continue to refresh, but user will not have access to it as long as pop-up is active).
- Need to have Silverlight-like effect when pop-up shows, meaning - 'Shell' needs to appear 'disabled' (like a gray mask over it).
- Pop-up window should have no 'X' button and no 'minimize' or 'maximize' buttons. The pop-up window should be simply a rectangle with curved-corners.
- I don't think I can use a 'Notification Window' or a 'Confirmation Window' because I cannot put inside them whatever I want. This is an example with 2 fields, but the pop-up might be much more complex with tabs, and a lot of information shown to the user.
- “Stock Trader RI”示例应用程序仅使用无模式对话框弹出窗口。我需要一个MODAL弹出窗口(背景将继续刷新,但只要弹出窗口处于活动状态,用户将无法访问它)。
- 弹出窗口显示时需要具有类似 Silverlight 的效果,这意味着 - “Shell”需要显示为“禁用”(例如上面的灰色蒙版)。
- 弹出窗口应该没有“X”按钮,也没有“最小化”或“最大化”按钮。弹出窗口应该只是一个带有弯角的矩形。
- 我不认为我可以使用“通知窗口”或“确认窗口”,因为我不能在它们里面放任何我想要的东西。这是一个包含 2 个字段的示例,但带有选项卡的弹出窗口可能要复杂得多,并且会向用户显示大量信息。
So how do I show a modal pop-up from my "WPF+PRISM" Shell-View-Model once the 'Edit' button is pressed ? (Meaning, once the 'EditCommand' is executed...)
那么,一旦按下“编辑”按钮,如何从我的“WPF+PRISM”Shell-View-Model 中显示模式弹出窗口?(意思是,一旦 'EditCommand' 被执行......)
回答by John Miner
I have found a solution here.
我在这里找到了解决方案。
Basically it uses InteractionRequestand it allows me to open a window (that I can style however I want, without the 'Maximize' 'Minimize buttons), and also - I can choose for it to be Modal.
基本上它使用InteractionRequest并且它允许我打开一个窗口(我可以随意设置样式,没有“最大化”“最小化”按钮),而且 - 我可以选择它是Modal。
Great thing about this solution is - that I can use custom pop-ups and not only Notification or Confirmation pop-ups.
这个解决方案的好处是 - 我可以使用自定义弹出窗口,而不仅仅是通知或确认弹出窗口。
Also - I can pass information back to the class the invoked the 'InteractionRequest'.
另外 - 我可以将信息传递回调用“InteractionRequest”的类。
Only thing that it doesn't solve - is that I cannot make the calling view look disabled by adding a gray semi-transparent over it ... haven't figured out yet how to do that...
它唯一无法解决的问题是我无法通过在其上添加灰色半透明来使调用视图看起来被禁用......还没有想出如何做到这一点......


