formaui-net.Framework.Culture.Blazor.WebView 1.0.0-preview.27

Prefix Reserved
This is a prerelease version of formaui-net.Framework.Culture.Blazor.WebView.
dotnet add package formaui-net.Framework.Culture.Blazor.WebView --version 1.0.0-preview.27
                    
NuGet\Install-Package formaui-net.Framework.Culture.Blazor.WebView -Version 1.0.0-preview.27
                    
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="formaui-net.Framework.Culture.Blazor.WebView" Version="1.0.0-preview.27" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="formaui-net.Framework.Culture.Blazor.WebView" Version="1.0.0-preview.27" />
                    
Directory.Packages.props
<PackageReference Include="formaui-net.Framework.Culture.Blazor.WebView" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add formaui-net.Framework.Culture.Blazor.WebView --version 1.0.0-preview.27
                    
#r "nuget: formaui-net.Framework.Culture.Blazor.WebView, 1.0.0-preview.27"
                    
#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.
#:package formaui-net.Framework.Culture.Blazor.WebView@1.0.0-preview.27
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=formaui-net.Framework.Culture.Blazor.WebView&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=formaui-net.Framework.Culture.Blazor.WebView&version=1.0.0-preview.27&prerelease
                    
Install as a Cake Tool

Forma.Framework.Culture.Blazor.WebView

What the culture state needs from a Blazor Hybrid application: by default, one culture for the whole application, across every web view in every native window, or, declared independent, one for each web view. Under the default, a switch made in any web view, or by the application's own native code, is applied to the one culture state, to the process's default cultures and to each web view's UI thread, so every event any web view dispatches after it runs in the new pair; each web view's document takes the pair's language and direction, and under culture routing its address moves into the pair's route, keeping the page and the user's work.

Use it

The package comes with formaui-net.Blazor.WebView, and AddFormaWebViewIntegration() registers it through AddFormaCultureWebViewIntegration():

Service Registered as
ICultureState Forma's own state, a singleton: one for the application.
ICultureSwitch The application's switch, a singleton, which a component and the host's native code both switch through.
ICultureStateIntegration The application's culture coordinator, which takes any pair applied through it as the application's next switch.
ICultureScopeInitializer Each web view's registration with the application's coordinator, scoped, which the web view's first Forma component initializes.
CultureCoordinatorRegistration Each web view's registration with its document's culture coordinator, scoped.

Each is added with TryAdd, so a host's own registration made first is the one used; a host that registers its own culture state registers it as a singleton, and one each web view resolves for itself is rejected with InvalidOperationException as its first component starts.

A web view takes part as its first Forma component initializes, starting in the application's pair, and leaves as it is disposed, leaving the culture to the application. Windows Forms disposes a web view with its form; a WPF host disposes its BlazorWebView as the native window closes, since WPF disposes no control on its own.

A culture per web view

AddFormaCultureWebViewIntegration(CultureArrangement.Independent), which AddFormaWebViewIntegration(options => options.CultureArrangement = CultureArrangement.Independent) makes, gives each web view a culture of its own:

Service Registered as
ICultureState Forma's own state, scoped: one for each web view.
ICultureSwitch The web view's switch, scoped, which requests each change through the web view's own document.
ICultureScopeInitializer Each web view's registration with its own document's culture coordinator, scoped, which the web view's first Forma component initializes from the web view's pair.
CultureCoordinatorRegistration Each web view's registration with its document's culture coordinator, scoped.

A switch in one web view, or a landing at another culture's address, changes that web view's state, its components, its document and its address alone. Forma applies no web view's pair to the process's or the UI threads' cultures, which every web view shares, so a component of the host's own reads its web view's ICultureState, and native code switches a web view through that web view's services. A host's own state is registered scoped; one two web views share is rejected with InvalidOperationException as the second starts.

Persistence

The switch persists the pair in the state alone. A native application keeps the user's choice in its own settings: it saves the pair as the state notifies it, and switches to the saved pair at startup, before its first web view opens. A cookie policy is rejected with InvalidOperationException as the coordinator, or under a culture per web view a web view's start, is first resolved, since no request carries a cookie to a server.

Culture routing

Pages a Web App shares with the application, culture route pages under CultureRouteScope, route as they do in the Web App, registered with AddFormaCultureRouting before or after AddFormaWebViewIntegration() under CultureSwitchMode.InPlace; a full-load switch is rejected with InvalidOperationException as the coordinator, or under a culture per web view a web view's start, is first resolved, since a web view reloads only by restarting its session. By default the application's culture decides each web view's address: a navigation to an address in another culture switches the application, and every web view then replaces its address with the same page in the new route; Back, Forward and a web view's first landing take the application's culture, never switching it.

A web view replaces its address through its navigation, so its location-changing handlers run for the replacement. A handler guarding the user's work lets it go on, since it keeps the page and the work:

using Forma.Framework.Culture.Blazor.WebView;

private ValueTask OnLocationChangingAsync(LocationChangingContext context)
{
    if (HasUnsavedWork && !context.IsCultureFollowing())
    {
        context.PreventNavigation();
    }

    return ValueTask.CompletedTask;
}

A handler that prevents the replacement keeps the web view's address, while its components and its document show the application's pair.

License

Apache License 2.0, under the repository's LICENSE.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on formaui-net.Framework.Culture.Blazor.WebView:

Package Downloads
formaui-net.Blazor.WebView

The WebView half of Forma's component library: the registration a Blazor Hybrid application makes, in WPF, Windows Forms or MAUI on Windows, or MAUI on Android, iOS or Mac Catalyst, which registers what the components need in a web view, the culture its web views keep, one for the whole application by default, or one for each web view, and the theme every web view draws, the application's.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.27 41 12/3/2026
1.0.0-preview.26 45 12/3/2026
1.0.0-preview.25 53 12/2/2026
1.0.0-preview.24 53 12/1/2026
1.0.0-preview.23 72 11/30/2026
1.0.0-preview.22 67 11/30/2026
1.0.0-preview.21 68 11/29/2026
1.0.0-preview.20 67 11/26/2026
1.0.0-preview.19 72 11/26/2026
1.0.0-preview.18 74 11/26/2026
1.0.0-preview.17 64 11/26/2026
1.0.0-preview.16 60 11/24/2026
1.0.0-preview.15 61 11/23/2026
1.0.0-preview.14 59 11/23/2026
1.0.0-preview.13 62 11/21/2026
1.0.0-preview.12 68 11/20/2026
1.0.0-preview.11 65 11/18/2026
1.0.0-preview.10 73 11/17/2026
1.0.0-preview.9 63 11/17/2026
1.0.0-preview.8 61 11/17/2026
Loading failed

What this release changed is in Forma's changelog: https://github.com/FormaUI/Forma/blob/v1.0.0-preview.27/CHANGELOG.md