question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Popup can't be made transparent by setting Opacity property

See original GitHub issue

I want to create a Dialog like this pic:

dialog-demo

Below is the xaml code of dialog content which is a UserControl and will be put in the Child of Popup:

<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             x:Class="AvaloniaApplication10.UserControl1">

  <Grid Background="Gray" Opacity="0.5" >

    <Border Width="200" 
            Height="200" 
            BorderBrush="Red" 
            BorderThickness="2" 
            Background="White">
      <TextBlock Text="Hello World Dialog!" />

    </Border>

  </Grid>

</UserControl>

I’ve subscribed the Bounds property of the MainWindow to make it to cover the full window. But the problem is Opacity=“0.5” has not effect. I also has set the Opacity property of the Popup, but still not working. I also have try to custom the PopupRoot Style, but still can’t make it work.

Is there any way to get this work? Thanks! (The project is Win32)

[EDIT] Just tested WPF and UWP, both can be made transparent by set their child’s transparency properly.

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            Popup po = new Popup();
 
            po.Child = new Border() { Width = 300, Height = 300, 
Background = Brushes.Beige, 
Opacity = 0.5};
            po.StaysOpen = true;
            po.AllowsTransparency = true;
            po.PlacementTarget = sender as FrameworkElement;

            po.IsOpen = true;
        }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ahoppercommented, Jul 10, 2020

Another way to achieve this is to use a panel covering everything else in your main window and avoid popups altogether.

0reactions
maxkatz6commented, Oct 17, 2021

Shouldn’t be an issue anymore. If it is - ping me here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use Opacity and Transparency to Create a Modal ...
Throughout this tutorial, you will use various ways to apply opacity and extra properties to effectively accomplish certain effects. You will ...
Read more >
Set the combobox's popup background transparent
If you want to have a Transparent background instead of a Black one, you'll have to set the AllowsTransparency property of the Popup...
Read more >
How to make a box semi-transparent - Learn web development
This guide will help you to understand the ways to make a box semi-transparent using CSS.
Read more >
How to Set Opacity of Images, Text & More in CSS
The first div is set to be completely opaque. ... You can use the CSS opacity property to make the background of an...
Read more >
Popup - How to set a transparency
Hello,. I need to set the background of certain dxPopup transparent programmaticaly, not using CSS and I can't figure it out
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found