MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Problem/Bug]: WebView2CompositionControl fails to correctly update visual hosting when moved to a new WPF Window

Open
#5,398 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

What happened?

When using WebView2CompositionControl (visual hosting mode) in a WPF application, the control becomes visually and functionally inconsistent after being moved to a new Window (different HWND) from the one it was originally created in.

Specifically, dropdown menus ( elements), context menus, and other popups become misaligned or render in incorrect positions after the move. We’ve identified that this happens because the control’s internal CoreWebView2Controller.Bounds and ParentWindow references are not automatically updated when the hosting window changes. We were able to mitigate this partially by using reflection to manually update CoreWebView2Controller.ParentWindow and recalculate the control’s bounds relative to the new window — but this should ideally be handled internally by WebView2. Steps to reproduce Create a WPF app using WebView2CompositionControl. Initialize the control in the main window (MainWindow). Move the control instance to a secondary window (for example, a floating tool window). Open a dropdown or context menu inside the WebView2 content.

Expected behavior
When the control is moved to a new parent window, all rendering and popup positioning should remain correct and relative to the new window.

Actual behavior

  • Popups (e.g., dropdowns or context menus) appear at incorrect screen positions, often relative to the original window’s coordinates. Calling WebView2Controller.NotifyParentWindowPositionChanged() does not fix the issue. The CoreWebView2Controller.Bounds appear to remain based on the original window. Importance Blocking. My app's basic functions are not working due to this issue. Runtime Channel Stable release (WebView2 Runtime) Runtime Version 141.0.3537.71 SDK Version 1.0.3065.39 Framework WPF Operating System Windows 11 OS Version No response Repro steps Create a WPF app using WebView2CompositionControl. Initialize the control in the main window (MainWindow). Move the control instance to a secondary window (for example, a floating tool window). Open a dropdown or context menu inside the WebView2 content
  • Repros in Edge Browser

    No, issue does not reproduce in the corresponding Edge version

    Regression

    No, this never worked

    Last working version (if regression)

    No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the listed WPF reproduction using WebView2CompositionControl, SDK 1.0.3065.39 and Runtime 141.0.3537.71, then move the control from MainWindow to a secondary window and test a dropdown or context menu. Done means popup rendering and positioning remain correct for the new window without reflection-based updates.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.