WebBrowser control is visible on top of the Ribbon Backstage

Docking/MDI for WPF Forum

Posted 8 years ago by Eric P
Version: 16.1.0631
Avatar

I am using the WPF System.Windows.Controls.WebBrowser control to display some HTML content in a ToolWindow. My View is defined like the following.

<UserControl … >
    <Grid>
        <ContentControl Content=”{Binding WebBrowser}” />
    </Grid>
</UserControl>

The ViewModel for this View is like the following.

public class MyViewModel : ToolItemViewModel {
    
    private WebBrowser _webBrowser;
    
    public MyViewModel() {
        WebBrowser = new WebBrowser();
    }

    public WebBrowser WebBrowser {
        get { return _webBrowser; }
        set { _webBrowser = value };
    }
}

This View gets wrapped in a ToolWindow for the DockSite using the ToolItemSource. There is one and only one WebBrowser control at one time.

<docking:DockSite ToolItemSource=”{Binding ToolItems}”
                  ToolItemContainerStyle=”{StaticResource ToolItemStyle}”>
</docking:DockSite>

When this ToolWindow is open and visible, and then I open the backstage on the ribbon, the browser control is drawing on top of the backstage. In the past I have tracked when the backstage becomes visible and I hide the browser control, this has worked well in the past. I also noticed that when this ToolWindow is hidden (unpinned) there is a lag for when the Browser becomes visible and/or becomes invisible within the ToolWindow.

I noticed that there is a web browser sample that talks about the Interop Compatibility. I have tried to use the InteropFocueTracking and the DockSite.UseHostedPopups but they do not seem to affect this issue.

If anyone has any suggestions how a better way to deal with this issue please let me know.

Comments (6)

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

Yes that is due to the WPF airspace issue with interop controls.  Ribbon's Backstage is implemented inline in the Window meaning any interop will appear on top of it, unlike if it were in a Popup or separate Window.  I would continue to recommend that you watch the Ribbon.IsApplicationMenuOpenChanged event and toggle the visibility of the interop (or an ancestor element) when it's open.


Actipro Software Support

Posted 8 years ago by Eric P
Avatar

I noticed that when the ToolWindow, that contains the WebBrowser, is hidden (un-pined) and I click its tab to have the Tool Window "slide out" the WebBrowser control is not show at all. If I move the mouse out of the tab (which is collapsed on the side) then suddenly the WebBrowser appears within the ToolWindow. Any suggestions?

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

Did you do the other settings mentioned in the Interop Compatibility topic?  It sounds like you might not have set the UseHostedPopups property to false.


Actipro Software Support

Posted 8 years ago by Eric P
Avatar

Yes you are correct. That was the issue. Thanks!

Posted 8 years ago by Eric P
Avatar

Ok so I have noticed two issues when setting UseHostedPopups="False" on the DockSite.

1). When the ToolWindows are unpined (auto-hidden) sometimes it takes two clicks to show the ToolWindow and sometimes it only takes one click. If UseHostedPopups is not used it always takes one click. It feels like it has something to do with what control has focus when I try to click the hidden ToolWindow tab.

2.) When UseHostedPopups="False" than any TextBlock controls draw their text black when they are unpined (auto hidden). If I pin the ToolWindow then the TextBlocks all draw white text as they should because I am uisng the Metro Dark theme. This does not seem to effect the Metro White or Light themes because they draw all TextBlock controls with black text when the ToolWindow is pined or unpined. Its like in the unpined ToolWindow the TextBlock style is not being applied correctly for Metro Dark

Lastly, does anyone have any experience with the following WPF based browser controls?

  1. http://cefsharp.github.io/
  2. https://wpfchromium.codeplex.com/
  3. https://awesomium.codeplex.com/

Would any of these allow me to display basic HTML content in our WPF applicaiton (in a ToolWindow) but not have any of the issues like air-space, with the out of the box WebBrowser control?

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Eric,

So far I'm unable to get eitther of the two issues to occur in the build 631 that came out this past Friday.  I'm testing in the Simple IDE after unchecking Options / Use Hosted Popups.  Are you able to reproduce either in that sample with that official build and if so, can you tell us exactly the steps to do so?

If not, can you make a new simple sample project that shows it happening and send that to our support address?  Please reference this thread in your email and rename the .zip file extension of what you send so it doesn't get spam blocked.  Thanks!


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.