如何在 wpf 屏幕上显示忙碌消息
嘿, 我有一个基于 Prism4 的 WPF 应用程序。当执行缓慢的操作时,我想显示一个繁忙的屏幕。我将拥有大量屏幕,因此我尝试在框架中构建单个解决方案,而不是向每个屏幕添加忙碌指示器。
这些长时间运行的操作在后台线程中运行。这允许更新 UI(好),但不会阻止用户使用 UI(坏)。我想做的是用旋转拨号盘之类的东西覆盖一个控件,并让该控件覆盖整个屏幕(带有 DIV 的旧 HTML 技巧)。当应用程序繁忙时,控件将显示,从而阻止任何进一步的交互并显示旋转的东西。
为了进行设置,我想我可以将我的应用程序屏幕与旋转的东西(具有更大的 ZIndex)一起放在画布中,然后根据需要使旋转的东西可见。
然而,这变得越来越困难。画布似乎没有为此做好准备,我想我可能找错了对象。
我将不胜感激任何帮助。谢谢。
Hey,
I have a WPF application based on Prism4. When performing slow operations, I want to show a busy screen. I will have a large number of screens, so I'm trying to build a single solution into the framework rather than adding the busy indicator to each screen.
These long running operations run in a background thread. This allows the UI to be updated (good) but does not stop the user from using the UI (bad). What I'd like to do is overlay a control with a spinning dial sort of thing and have that control cover the entire screen (the old HTML trick with DIVs). When the app is busy, the control would display thus block any further interaction as well as showing the spinny thing.
To set this up, I thought I could just have my app screen in a canvas along with the spinny thing (with a greater ZIndex) then just make the spinny thing visible as required.
This, however, is getting hard. Canvases do not seem well set up for this and I think I might be barking up the wrong tree.
I would appreciate any help. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经用几个程序做到了这一点。简而言之:(
这对于 MVVM 来说是最简单的。自从我使用代码隐藏来做这样的事情以来已经很长时间了,我真的不能说是否有一个好的方法来做到这一点。)
科里
编辑:
I have done this with a few programs. Here it is in a nutshell:
(This is easiest with MVVM. It has been so long since I used the codebehid for things like this I can't really say if there is a good way to do it.)
Cory
Edit:
查看带有繁忙指示器的 WPF 工具包: https://github.com/xceedsoftware/wpftoolkit/维基/BusyIndicator
Look at this WPF toolkit with a busy indicator: https://github.com/xceedsoftware/wpftoolkit/wiki/BusyIndicator
我通过简单地显示一个对话框(因此用户无法与其他任何内容交互,它将显示在顶部)来完成此操作,然后处理 Closing 事件(因为用户可以按 Alt-F4)以查看操作是否已完成,否则我会取消闭幕式活动:
I do this by simply displaying a dialog (so the user cannot interact with anything else and it will be displayed on top) then handle the Closing event (as the user could press Alt-F4) to see if the operation has finished otherwise I cancel the closing event: