UWPHybridWebView 1.0.0

dotnet add package UWPHybridWebView --version 1.0.0
NuGet\Install-Package UWPHybridWebView -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UWPHybridWebView" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UWPHybridWebView --version 1.0.0
#r "nuget: UWPHybridWebView, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UWPHybridWebView as a Cake Addin
#addin nuget:?package=UWPHybridWebView&version=1.0.0

// Install UWPHybridWebView as a Cake Tool
#tool nuget:?package=UWPHybridWebView&version=1.0.0

UWP Hybrid WebView

This repo .NET UWP Hybrid Web View control, which enables hosting arbitrary HTML/JS/CSS content in a WebView and enables communication between the code in the WebView (JavaScript) and the code that hosts the WebView (C#/.NET).

It is possible to convert web applications to Windows application mode and even use it in kiosk mode. Access to Windows functions is also preserved in place.

You can use this for Vue, React and Angular projects.

Github: See Github Repo

Usage

<Page
    ...
    xmlns:hwv="using:HybridWebView">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <hwv:HybridWebView x:Name="webview" 
                           AppName="VueApp"
                           AppPath="Raw/hybrid_root"
                           AllSensorsAccess="True"/>
    </Grid>
</Page>

Methods

You can use this method for call a method from Js.

ExecuteJsScriptAsync(string methodName, string[] args)

Example:

string[] names = { "'John'" };

webview.ExecuteJsScriptAsync("SayMyName", names);
webview.ExecuteJsScriptAsync("JsMethod", null);

Pay attention that the function on the Js side must also be defined as below.

window.{MethodName} = function ()
{
    ...
}

Example:

window.JsMethod = function ()
{
    alert("Js Method");
}

window.SayMyName = function (name)
{
    alert(name);
}

Events

To receive messages sent from the JS side, the event must be used.

public MainPage()
{
    this.InitializeComponent();

    webview.HybridWebViewMessageReceived += OnHybridWebViewMessageReceived;
}


private async void OnHybridWebViewMessageReceived(object sender, string message)
{
    ...
}

To send a message from the Js side to the C# side, you must proceed as follows.

//You can write any message
let message = "Any Message";

if (window.chrome && window.chrome.webview)
{
    window.chrome.webview.postMessage(message);
}
else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.webwindowinterop)
{
    window.webkit.messageHandlers.webwindowinterop.postMessage(message);
}
else
{
    window.hybridWebViewHost.sendMessage(message);
}
Product Compatible and additional computed target framework versions.
Universal Windows Platform netcore50 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 104 1/14/2024

UWP HWV(Hybrid Web View) V1.0.0