Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opacity is not getting applied to the WPF Popup control

Popup popUpControl = new Popup();

popUpControl.PlacementTarget = this; 
popUpControl.StaysOpen = true;
popUpControl.Child = new MyUserControl(); /// my user control 
popUpControl.Opacity = 0.5; // this code has no effect in the appearance of the popup
popUpControl.IsOpen = true;

How to do it?

like image 694
Subindev Avatar asked Dec 02 '09 03:12

Subindev


2 Answers

You should Enable Popup to have Transparency. Add following line of code.

popUpControl.AllowsTransparency=true;
like image 194
Sasikumar D.R. Avatar answered Nov 10 '22 12:11

Sasikumar D.R.


You need to set the opacity on the popup content.
So for your button have

popUp.Child = new Button() 
{
    Width = 300,
    Height = 50,
    Background = Brushes.Gray,
    Opacity = 0.5 // set opacity here
};
like image 37
Jay Avatar answered Nov 10 '22 13:11

Jay