This tip is about Airspace problem. When Winform/Browser is rendered in conjunction with WPF, then overlapped region is relinquished by WPF. This article uses a simple approach to handle this issue.
Introduction
Mixing Winform/Browser with WPF causes rendering issue on the coinciding area. I am attaching a quick solution in case anybody is stuck for the same. We attached another WPF window into the specific XAML location and that takes care of Airspace issue. The solution contains a very basic example and I hope it will provide you with a pointer to start.
Using the Code
The demo app is having one Main Window which contains three noticeable children:
WinformHost
Browser
OverlayContainer
<local:OverlayControl x:Name="OverlayContainer" Grid.Row="2"
Grid.RowSpan="2" Grid.ColumnSpan="2" Height="100" VerticalAlignment="Center">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
<TextBlock Text="This is overlay content
" Grid.Column="0" HorizontalAlignment="Left" Background="Orange"/>
<TextBlock Text="This is another overlay content"
Grid.Column="1" HorizontalAlignment="Right" Background="Orange"/>
</Grid>
</local:OverlayControl>
OverlayContainer
is a wrapper control where you can provide intended content to render on top of WinformHost
/Browser
. This container injects another WPF window into the region supplying its own content. OverlayWindow
is the one being injected. Extended HwndHost
is used to glue WPF window into OverlayContainer
.
History
- 1st March, 2022: Initial version