[Problem/Bug]: WebView2CompositionControl fails to correctly update visual hosting when moved to a new WPF Window
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 (
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
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.,
- 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
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