Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WPF

Airspace Solution

5.00/5 (9 votes)
28 Feb 2022MIT 8.7K   477  
A simple approach to handle Airspace problem
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:

  1. WinformHost
  2. Browser
  3. OverlayContainer
XML
<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

License

This article, along with any associated source code and files, is licensed under The MIT License