WebView2 Sample

The WebView2 control lets you embed web content in your Windows desktop applications. Below is a minimal example that demonstrates how to create and use WebView2 with the Windows App SDK.

Sample Code

#include <winrt/Windows.UI.Xaml.Controls.h>
#include <winrt/Microsoft.Web.WebView2.Core.h>

using namespace winrt;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Microsoft::Web::WebView2::Core;

int main() {
    Application::Start([](auto &&) {
        Window window = Window::Current();
        WebView2 webView;
        webView.Source(uri(L"https://www.bing.com"));
        window.Content(webView);
        window.Activate();
    });
}

Live Demo