Microsoft.Toolkit.Win32 icon indicating copy to clipboard operation
Microsoft.Toolkit.Win32 copied to clipboard

[Question] Is it possible to host a WebView control in a C++ Win32 app?

Open mlantas opened this issue 5 years ago • 2 comments

Hello,

I am trying to host a WebView control (Windows::UI::Xaml::Controls::WebView) in my C++ Win32 app. I saw that the docs listed the following as a limitation:

Adding a WebView control to a custom user control (either on-thread, off-thread, or out of process).

For that reason I followed the Host a standard UWP control instructions. Since it's not a "custom control" I assumed it would work. However, with the following code, an exception (hresult_error) is always raised on the Navigate method call.

Windows::UI::Xaml::Controls::WebView wv;
wv.Navigate(Windows::Foundation::Uri(L"https://bing.com"));

My use-case is that I want to place a WebView inside a UWP StackPanel or similar control. Is there something I'm missing, or are WebView controls not supported at all in Win32?

Thank you, Max

mlantas avatar Apr 22 '20 05:04 mlantas

Hello mnxn, thank you for your interest in Win32!

I have automatically added a "needs triage" label to help get things started. Our team will look into the question and answer ASAP. Other community members may also answer the question and provide feedback 🙌

ghost avatar Apr 22 '20 05:04 ghost

Hi @mnxn, I'd suggest trying the WebView2 preview for your scenario. It will be replacing the WebView in this repository, and their current preview is geared towards C++ hosting.

michael-hawker avatar Apr 28 '20 17:04 michael-hawker