RFBCodeWorks.Mvvm.WebView2Integration 1.0.1.1

dotnet add package RFBCodeWorks.Mvvm.WebView2Integration --version 1.0.1.1
NuGet\Install-Package RFBCodeWorks.Mvvm.WebView2Integration -Version 1.0.1.1
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="RFBCodeWorks.Mvvm.WebView2Integration" Version="1.0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RFBCodeWorks.Mvvm.WebView2Integration --version 1.0.1.1
#r "nuget: RFBCodeWorks.Mvvm.WebView2Integration, 1.0.1.1"
#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 RFBCodeWorks.Mvvm.WebView2Integration as a Cake Addin
#addin nuget:?package=RFBCodeWorks.Mvvm.WebView2Integration&version=1.0.1.1

// Install RFBCodeWorks.Mvvm.WebView2Integration as a Cake Tool
#tool nuget:?package=RFBCodeWorks.Mvvm.WebView2Integration&version=1.0.1.1

RFBCodeWorks.Mvvm.WebView2Integration

This is a helper namespace to allow MVVM binding to navigation events generated by the Microsoft WebView2 object

IWebView2NavigationHandler

  • This interface is used to react to the NavigationStarted and NavigationCompleted events generated by WebView2.

IWebView2NavigationHandlerExpanded

  • This interface expands the amount of event handlers that are implemented,

WebView2BindingHelper

  • This is a FrameWorkElement that must be added to the XAML to facilitate the event binding.
  • Bind the WebView and an IWebView2NavigationHandler to allow for MVVM handling of the WebView2 navigation events.
  • This object has a strong reference to the WebView2 object, as it must listen to the events.
  • The IWebView2NavigationHandler methods are invoked when a WebView2 event occurs, and are not directly tied to the WebView2 control, facilitating a weak reference methodology via the binding.
  • Provides the NavigationHandler class that implements the required interface to allow for easy integration into existing viewmodels.

    • Add the NavigationHandler to your viewmodel, then assign it the event delegate you wish to invoke when the event occurs.
    • Finally, bind it all in xaml using the WebView2BindingHelper xaml object
  • Using this class, you can structure your ViewModel in such a way that all events are available to react against, but you only need to implement the desired few.

Example Usage:

xmlns:MyWebView="clr-namespace:RFBCodeWorks.Mvvm.WebView2Integration;assembly=RFBCodeWorks.Mvvm.WebView2Integration"

<grid>

<WebView:WebView2 x:Name="WV" Source="{Binding InitialSource}" />

<MyWebView:WebView2BindingHelper WebView="{Binding ElementName=WV}" NavigationHandler="{Binding NavigationHandler}"/>

</grid>


MyNavHandler = new NavigationHandler() { NavigationStartingHandler = PreventPageNavigation, NavigationCompletedHandler = OnNavigationComplete, };

private void PreventPageNavigation(object sender, CoreWebView2NavigationStartingEventArgs e) { e.Cancel = true; }

private void OnNavigationComplete(object sender, EventArgs e) { // do something }

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net5.0-windows7.0 is compatible.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net472 is compatible.  net48 is compatible.  net481 was computed. 
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.1.1 227 11/10/2023
1.0.1 92 11/3/2023

- Initial Release