WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

Why does the WebView2 for .NET provide the CoreWebView2CompositionController but dose not implement its interfaces?

Open XuanchenLin opened this issue 1 year ago • 1 comments

Describe the feature/enhancement you need

Previously, I developed a WinForm user interface framework called NanUI, which can use HTML/CSS/JS to desgin the user interface of the application. It can be understood as the WinForm version of Electron. This framework is based on CEF. Recently, I want to switch the HTML rendering component from CEF to WebView2 to reduce the size of the application after release.

I have completed the code using the DirectComposition API in WinForm. According to the API reference document of WebView2, I simply thought that I only needed to create a CoreWebView2CompositionController and provide a ContainerVisual for its RootTarget property to successfully complete my goal. But when I did this, I found that CoreWebView2CompositionController did not provide the CoreWebView2 property, so I couldn't even use the Nevigate method to specify a target URL. Of course, many methods and properties provided in the CoreWebView2Controller object are missing in CoreWebView2CompositionController, such as the Bounds property for setting the size of WebView2 and the NotifyParentWindowPositionChanged method for notifying WebView2 when the position of parent window changed.

My question is, will these properties and methods missing in CoreWebView2CompositionController be provided in future updates?

The scenario/use case where you would use this feature

The reason for using CoreWebView2CompositionController instead of directly using WebView2 control is to achieve the goal of compositing webpage (possibly with transparent background) with window material effects (such as Mica effect in Windows 11).

How important is this request to you?

Critical. My app's basic functions wouldn't work without it.

Suggested implementation

I don't know why these missing properties and methods are not provided in CoreWebView2CompositionController. Is it because the WebView2 development team thinks it is unnecessary?

What does your app do? Is there a pending deadline for this request?

I want to use WebView2 to render a web page and composite it with a WinForm as the user interface of the application.

XuanchenLin avatar Jun 14 '24 19:06 XuanchenLin

Hello @XuanchenLin there currently aren't plans to implement CoreWebView2CompositionController for .NET. You may be able to achieve your scenario with our upcoming WebView2CompositionControl class. It is currently available in prerelease but is not fully functional: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.wpf.webview2compositioncontrol?view=webview2-dotnet-1.0.2646-prerelease

johna-ms avatar Aug 05 '24 23:08 johna-ms

Hi @johna-ms, thanks for answering my question.

I am sorry to know that CoreWebView2CompositionController will not be implemented in .NET. Then I can only continue to use CEF as a core component in my project. So it seems that the plan to switch from CEF to WebView2 is not possible yet.

Hope to hear good news in the near future.

XuanchenLin avatar Aug 06 '24 05:08 XuanchenLin