Skip to content

Provide an official solution to use CoreWebView2CompositionController in WinUI 3 environment #3439

@GetGet99

Description

@GetGet99

Is your feature request related to a problem? Please describe.

Yes, it does. Currently, the WebView2 component in Microsoft.UI.Xaml.Controls.WebView2 has limited functionality that if I have access to CoreWebView2CompositionController, I may be able to add more functionality to WebView2 control. For example, WebView2 control in UWP and WinUI 3 lacks the ability to set the default background color, but it is possible to set them using the CoreWebView2CompositionController object.

In the UWP environment, these problems can be resolved by manually creating WebView2 control by ourselves using CoreWebView2CompositionController and handling pointer and key events, and setting the RootVisualTarget tp a Windows.UI.Composition.Visual object. In UWP, it can be resolved by setting the default background color from the CoreWebView2CompositionController.

In WinUI 3, however, most of the composition APIs are using Microsoft.UI.Composition.Visual. As far as I am aware, it is impossible (or maybe I haven't figured out how to do this yet) to get IDCompositionVisual or Windows.UI.Composition.Visual from it. But I do need them to set the visual to CoreWebView2CompositionController because it does not accept the Microsoft.UI.Composition.Visual object.

Describe the solution you'd like and alternatives you've considered

I would like an API that allows us to use CoreWebView2CompositionController in WinUI 3 in the way that it shows the web view in the interface. One of the ways is to have an API to set RootVisualTarget to Microsoft.UI.Composition.Visual. Since I am not sure how WinUI 3 internally works, the team may consider working on other kinds of API alternatives to accomplish the same goal.

As stated in the problem part, I am not aware of any alternatives right now.

Finally, I would like to state these to make it clear that

  1. This issue is not related to exposing or not exposing the CoreWebView2CompositionController object from WebView2 control itself in any platform.
  2. This issue is not related to adding or not adding more APIs to the associated WebView2 control in any platform. I am stating this because CoreWebView2CompositionController may get updated in the future and WebView2 control in each platform may not utilize the new APIs, but this ensures that users who want to integrate new features can do so before the official WebView2 control in each platform gets updated.

AB#45813100

Metadata

Metadata

Assignees

Labels

feature requestfeature requesttrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions