How to display a layer over all Controls [closed]

2020-07-27 03:37发布

I've got a Window which opens a borderless Dialog where you select some options. Once the options are set the Dialog closes and the main Window is enabled again. Not too difficult.

But due to the changed options in the option screen I need to refresh the main window and prevent changes from beeing made before the refresh.

So now I'd like to add and extra layer with a ProgressBar in the middle to notify the user: please wait, we are refreshing.

What would be the best practices around this?

标签: wpf
2条回答
看我几分像从前
2楼-- · 2020-07-27 04:14

You could take a look at Adorners (MSDN link) which allows you to stick a rendering surface on top of other UI Elements. That would allow your existing controls to be ignorant of the refreshing stage and allow incapsulation of the progress-visualization inside the Adorner and the chunk of code that is required to show/hide the Adorner layer

查看更多
冷血范
3楼-- · 2020-07-27 04:25

I just learned about the Popup primitive control. It isn't modal, but it does overlay other controls on the screen.

You could, hypothetically, open a popup that covers the entire window (you'll have to move it if the user moves the window) that has a transparent background with an opaque centered panel that displays your wait message. Add a tinted transparent background to the popup for a dimmed UI experience.

查看更多
登录 后发表回答