-
Couldn't load subscription status.
- Fork 62
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