Opacidade não está sendo aplicada ao controle WPF Popup
Pergunta
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;
Como fazê-lo?
Solução
Você precisa definir a opacidade do conteúdo popup.
Assim, para o seu botão Com
popUp.Child = new Button()
{
Width = 300,
Height = 50,
Background = Brushes.Gray,
Opacity = 0.5 // set opacity here
};
Outras dicas
Você deve habilitar Popup ter transparência. Adicione o seguinte linha de código.
popUpControl.AllowsTransparency=true;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow