2

So I have a control in my application that I wanted to utilize the popup for. It is has a WebBrowser control that is a part of it.

I notice that whenever I set the following property only the WebBrowser control disappears on my custom control.

.AllowsTransparency = true;

However, if I remove the property the control looks normal and functions normal. The only reason I am setting that property is because it the control utilizes rounded borders and by default the Popup control has a black background.

This same behavior exists in a Window if you set the AllowsTransparency property to true.

Just to note you can simulate this behavior on a brand new control with no special properties. I have tested both on a new control and a new window.

Any help is appreciated.

Edit

This occurs when the WebBrowser is set to DesignMode = On.

Steven Combs
  • 1,890
  • 6
  • 29
  • 54

2 Answers2

4

The WebBrowser is not a native WPF control. It is actually just internally creating an ActiveX WebBrowser control. HwndHost's (like WebBrowser) cannot be placed into a Window/Popup whose AllowsTransparency is true because that enables layered windows (i.e. includes the WS_EX_LAYERED style).

AndrewS
  • 6,054
  • 24
  • 31
  • I will add this here and edit my question. I think the issue occurs specifically when Design Mode is set to on also. This is primarily when the WebBrowser control disappears. I apologize to both Answer posters for not providing this initially. – Steven Combs May 02 '12 at 19:20
-1

I am not sure what you're doing there. Without code, it's hard to tell. But my guess, is that you are not setting the background of the inner border control. Just put this code in a new solution and there shouldn't be any problems, everything is visible:

<StackPanel >
    <Popup IsOpen="True" AllowsTransparency="True">
        <Border Padding="10" Width="250" Height="250" Opacity="1" BorderBrush="Black" BorderThickness="1" CornerRadius="3">
            <Border Background="Black">
                <StackPanel>
                    <TextBlock Foreground="White" Margin="5,25,5,5" HorizontalAlignment="Center">tata</TextBlock>
                    <Button Background="Black" Foreground="White" BorderBrush="Silver" HorizontalAlignment="Center">ok</Button>
                </StackPanel>
            </Border>
        </Border>
    </Popup>
 ......
denis morozov
  • 6,236
  • 3
  • 30
  • 45
  • Have you tested this with a WebBrowser control? I have implemented the following code you have provided in a new solution and the WebBrowser control still disappears. All other content is fine, including buttons, textblock, etc. – Steven Combs Apr 12 '12 at 14:52