Skip to main content

WPF and HwndHost Descendant Interoperation Limitations

  • 2 minutes to read

You can embed HwndHost descendant (WindowsFormsHost, WebBrowser, WebView2, and other) controls into WPF applications, as described in WPF and Win32 Interoperation Overview.

Limitations

  1. When you embed HwndHost descendant controls in WPF applications, controls are always displayed on top of WPF controls.

    As an example, the DockLayoutManager’s dock panel contains a WinForms control. If you move other panels over that panel, they are hidden (placed behind the WinForms control).

  2. HwndHost descendant controls cannot be displayed in WPF windows whose AllowsTransparency property is true.

    The AllowsTransparency property is set to true for each of DockLayoutManager‘s panels. This ensures that the panel’s borders and shadows are displayed correctly. However, WinForms controls are hidden when they are displayed within windows that support transparency.

Bypass Limitations

Set the DockLayoutManager.EnableWin32Compatibility property to true to bypass possible issues with auto-hide and floating panels that are overlapped by HwndHost descendant controls.

In this case, the AllowsTransparency property is also set to false for all floating WPF windows and force auto-hide panels to be drawn over a WindowsFormsHost object. The DockLayoutManager.EnableWin32Compatibility property is in effect for floating panels only when the DockLayoutManager.FloatingMode is set to Desktop.

HwndHost Descendant Controls in AutoHide Groups

If you place a HwndHost descendant control in an AutoHideGroup, set the DockLayoutManager‘s AutoHideGroupsCheckInterval property to 00:00:00:05. In this case, the AutoHideGroup will be hidden if you hover another layout element.