CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

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

Open mnxn opened 4 years ago

mnxn commented 4 years ago

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

ghost commented 4 years ago

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 🙌

michael-hawker commented 4 years ago

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.