Domanda

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?

È stato utile?

Soluzione

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;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top