How to get a CoreWebView2Controller from an instance of CoreWebView2CompositionController? #4621
Unanswered
XuanchenLin
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I was recently looking at the WebView2SampleWinComp sample code, and I wanted to use the Visual of webview2 in WinForm. The code for the DirectComposition API part has been done, but I found some problems when I wanted to use webview2.
I used CoreWebView2Environment.CreateAsync to create an environment instance, and used the CreateCoreWebView2CompositionControllerAsync method to create a compController object.
However, the CoreWebView2CompositionController class does not inherit from the CoreWebView2Controller class, so I cannot use the properties and methods of the CoreWebView2Controller from the compController object. This results in that although I can get the Visual of WebView2 and add it to the VisualTree, but I cannot control WebView2, such as using NotifyParentWindowPositionChanged to notify WebView2 that the parent window position has changed or using Bounds to change the size of WebView2's Visual.
So I want to know if there is any way to get the CoreWebView2Controller from an instance of CoreWebView2CompositionController?
In the WebView2SampleWinComp sample, I found that the C++ code was able to use QueryInterface to do this. But I didn't find a similar way in C# by using Microsoft.Web.WebView2.Core .
Sorry for my English.
Please help, thanks!
Beta Was this translation helpful? Give feedback.
All reactions