Popup AllowTransparency is killing WebBrowser child - wpf

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.

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).

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>
......

Related

Wpf, AvalonEdit and keyboard navigation problem

I have an AvalonEdit on my window. When I press key combination Ctrl+Up or Ctrl+Down when inside editor, AvalonEdit loses focus, which is transferred to a different control, as below:
This sometimes happen as well when using Ctrl+Left or Ctrl+Right combinations.
My current XAML definition looks like following:
<ae:TextEditor x:Name="teEditor"
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
BorderThickness="0"
FontFamily="Consolas"
FontSize="10pt"
TabIndex="0"
WordWrap="{Binding ElementName=Root, Path=Handler.WordWrap}"
ShowLineNumbers="{Binding ElementName=Root, Path=Handler.LineNumbers}"
ContextMenu="{StaticResource EditorContextMenu}"
GotFocus="HandleEditorGotFocus"
KeyboardNavigation.ControlTabNavigation="None"
KeyboardNavigation.AcceptsReturn="True"
KeyboardNavigation.DirectionalNavigation="None"
KeyboardNavigation.TabNavigation="None"/>
How can I prevent that?
It turns out, that problem appears, when you place AvalonEdit inside TabControl. In such case you have to disable keyboard navigation on the TabControl by adding:
KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained"

WPF Rounded Corners on a Border in a Window Without AllowsTransparency

I have a problem similar to this, but I have a window that cannot have "AllowsTransparency=True" because the WebBrowser inside it would be rendered invisible. The corners of the window come out black and I need them to be transparent.
Changing the background color to transparent has no effect. I've found that you can wrap a border with rounded edges around a popup with this problem, but you can't do that with a window.
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Background="Transparent" AllowsTransparency="False">
<Border Padding="0" Margin="0" BorderThickness="1" CornerRadius="100" Background="AliceBlue">
<StackPanel>
<TextBlock HorizontalAlignment="Center">v This is a webbrowser v</TextBlock>
<Border BorderBrush="red" BorderThickness="5">
<WebBrowser />
</Border>
</StackPanel>
</Border>
</Window>
Any ideas?
---EDIT---
I've tried every form of the WebBrowser Overlay solution, but my specific problem can't use it. I need a solution that has AllowsTransparency="False".
You seems to have a problem of interop between webbrowser window and a wpf window
so when you set wpf window to be transparent it effectively make the browser transparent as browser is in the hierarchy of the main window
so the whole idea to overcome this issue is to host a browser in a separate native window and overlay it on the transparent wpf window
you may follow WebBrowser control on transparent WPF window

WPF : How to animate element width whenever it changes

This should be easy but I'm blanking out here.
I have a TextBlock inside of a Border control. The Width of the Border changes based on the length of the text in the TextBlock (updated in ViewModel). I would like this change in Width to be animated so that the width grows slowly (instead of jerky).
My Xaml:
<Border x:Name="myBorder" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" VerticalAlignment="Top">
<TextBlock x:Name="myTextBlock" HorizontalAlignment="Left" Text="Some Text"/>
</Border>
This is a perfect job for Expression Blend. You will need to create a Storyboard animation. Then once its created go into the code behind in visual studios and play it. You can tell it to play to a certain point based on how much text you have in your text block.
Here is a basic tutorial
http://www.silverlightbuzz.com/2009/10/12/animating-with-storyboards-in-blend/
This example has back end code also
http://dotnet.dzone.com/articles/wpf-storyboard-%E2%80%93-what-it-and

Windows phone layer

How can I create the effect similar to Windows Phone's MessageBox, where the message gets displayed on a new layer with transparent background, so that the windows becomes modal? My layout is created out of Grid, so I do not know how to add any content over it. Please help.
It's easy to overlay one set of content with another in WPF. Try changing the visibility of the border below, for a simple message box effect. You would of course bind Visibility to your view model, or set it in code behind.
<Grid>
<Grid>
<!-- All your layout here -->
</Grid>
<Border Height="100" Width="100" Background="Azure" Visibility="Hidden">
<TextBlock Text="Hi there" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Grid>

Silverlight Border object not visible when theme applied?

I have a applied one of the Silverlight Toolkit themes to my XAML page, and now for some reason my Border objects don't show up. Is this by design? I've made sure to explicitly state a BorderBrush color that should contrast the theme background, but this does not fix the issue.
In case it helps, the theme I'm using is the BureauBlack theme from the Silverlight Toolkit.
And here is a code snippet of one of my Borders.
<Border VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Grid.RowSpan="2" BorderBrush="Orange" CornerRadius="10" Margin="0" Height="300">
<StackPanel>
<TextBlock Text="Status Panel" FontSize="20" TextAlignment="Center" />
...
</StackPanel>
</Border>
It looks like when a theme is loaded it loads its own default set of values for most object properties. In this case, the BorderThickness property of the border object defaults to 0. As a result you don't see it.
By explicitly giving the BorderThickness property a value (non-zero ofcourse), I got my border to show up.
In addition, I can recommend Silverlight Spy tool.
One of the feature of Silverlight Spy is to provide a tree of all controls, to display all their properties and to provide an ability to dynamically change them. It greatly decrease time for such problem resolving.
I've used it several times in cases like your.

Resources