Click here to Skip to main content
15,868,164 members
Articles / Desktop Programming / WPF
Tip/Trick

Airspace Solution

Rate me:
Please Sign up or sign in to vote.
5.00/5 (9 votes)
28 Feb 2022MIT 7.4K   412   4   2
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


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
zegreatclan1-May-23 20:20
zegreatclan1-May-23 20:20 
Praisegood idea Pin
JHM@KOR13-Sep-22 21:37
JHM@KOR13-Sep-22 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.