BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News .NET MAUI 9 Preview 7: Introduction of HybridWebView and Other Improvements

.NET MAUI 9 Preview 7: Introduction of HybridWebView and Other Improvements

The .NET 9 Preview 7 release includes significant updates to .NET MAUI, such as the introduction of HybridWebView and the deprecation of the MainPage property. It also introduces new lifecycle methods for managing remote notifications on iOS and also enhancements to Native Embedding capabilities and more.

The first notable addition is the HybridWebView, which allows developers to host HTML, JavaScript, and CSS content within a WebView. This feature supports communication between the hosted WebView content and the host application code. It enables the integration of a React JS application within a .NET MAUI native app, with backend development in C# and .NET. For interested readers, detailed implementation guidance is available in the official release notes on GitHub.

Another significant update is the introduction of the TitleBar control and the Window.TitleBar property for Windows. The new TitleBar control, derived from ContentView, allows developers to design custom title bars for their applications and can be placed anywhere within the application.

(Usage of TitleBar control, Source: Official GitHub .NET MAUI release notes)

The Window.TitleBar property enables the setting of a TitleBar control at the top of the application window. A note that this feature is currently available for Windows projects and it is stated that it will be introduced for Mac Catalyst in a future release.

The ActivateWindow method has been added to facilitate bringing a specific window to the foreground on Mac Catalyst and Windows platforms. This method can be used as follows:

Application.Current?.ActivateWindow(secondWindow);

The BackButtonBehavior now supports BindingMode.OneWay for its IsVisible and IsEnabled properties, replacing the previous BindingMode.OneTime. This update allows for more dynamic control over the back button’s behavior through data bindings during runtime.

The release includes changes to BlazorWebView backward compatibility. The default host address for BlazorWebView content has been updated to localhost on iOS and Mac Catalyst 18 and newer versions. The previously used internal address 0.0.0.0 no longer functions, resulting in the BlazorWebView rendering as an empty rectangle. To continue using 0.0.0.0, developers must activate this behavior with a switch in MauiProgram.cs:

AppContext.SetSwitch("BlazorWebView.AppHostAddressAlways0000", true);

Furthermore, now with Preview 7, the MainPage is marked obsolete. Developers should now set the Page directly on the Window, reflecting the previous behavior of the MainPage property in .NET MAUI applications. The MainPage property will be completely removed in a future release, although it remains available in .NET 9 to assist with the transition from Xamarin.Forms.

This update also includes improvements in Native Embedding, allowing the integration of .NET MAUI controls into .NET applications for Android, iOS, Mac Catalyst, or WinUI, eliminating the need for a compatibility package.

Additional updates in this release include a new Handler disconnect policy, a new ProcessTerminated event for the WebView control, and new lifecycle methods for remote notifications on iOS and Mac Catalyst. The release also includes Xcode Sync (xcsync) for CLI and Visual Studio Code.

The release includes quality improvements for .NET for iOS and .NET for Android. Full release notes for .NET MAUI updates in .NET 9 Preview 7 are available on GitHub.

About the Author

Rate this Article

Adoption
Style

BT