I am building a WPF application in C#.NET and I would like to grey out the window and display a StackPanel in the centre, if a condition is true, like the glass pane in Java. I will be selling my application so I would prefer not that have to ship another licence with it, and it really needs to be free.

Is there any code to let me do this?

有帮助吗?

解决方案

Just apply a MonochromeEffect from the WPF Shader Effect Library whenever you popup a dialog:

When opening a dialog:

Application.Current.MainWindow.Effect = new MonochromeEffect() { FilterColor = Color.FromArgb(255, 90, 90, 90) };

When closing a dialog:

Application.Current.MainWindow.Effect = null;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top