Categories
.NET .NET 9 .NET MAUI Android Blazor C# Desktop Developer F# General Getting Started Hybrid iOS macOS Mobile Visual Studio VS Code Web What's New Windows Xamarin Xamarin.Forms

What’s New in .NET MAUI 9: A Comprehensive Overview

.NET 9, the next major version of .NET following the annual release cadence, will be a Short-Term Support (STS) release, which will be supported for 18 months from release.

This release is packed with a broad set of features. The primary highlight is the support for Native AOT across app models.

In this article, we’ll explore the high-level features of .NET MAUI 9.

  • Multi-target versions of .NET for iOS bindings
    • Ability to build an iOS binding library for multiple versions from a single project
    • <TargetFrameworks>net9.0-ios17.0;net9.0-ios17.2</TargetFrameworks>
    • When submitting to the App Store, the app should always target the latest iOS SDK
  • Android Asset Packs
    • Efficiently distribute the on-demand assets
    • Saves bandwidth costs for the end user
  • New Input Keyboards for Entry
    • Customize Keyboards for better UX
    • Support for Date, Password, and Time
    • <Entry Keyboard="Password" />
  • Native AOT for iOS and Mac Catalyst
    • The primary objective of this .NET version
  • LLVM Marshalled Methods for non-Blazor Android apps
    • Improves startup performance
  • HybridWebView
    • Another control quite like BlazorWebView
    • For hosting JavaScript-based SPA as Hybrid apps
    • Interaction between JS and .NET
    • MAUI as App Container
    • To gain further insights, consult this article.
    • A new project template utilizing this new control is now available in the All-in-One Templates pack. For more info, please refer to this article.
  • TitleBar controls for Windows
    • Same look and feel of the Store apps
    • Tall TitleBar
    • Host controls on the TitleBar
    • Support for MacCatalyst coming soon – Track here
      • Update: Released as part of .NET MAUI 9 SR4 – v9.0.40
    • For in-depth details, refer to this article
  • ActivateWindow() method to bring a Window to foreground
    • Bring an already-created Window to the foreground in a multi-window app
    • Application.Current?.ActivateWindow(windowInstance);
  • BindingMode for BackButtonBehavior is updated to OneWay instead of OneTime
    • Customize the behavior of BackButton
  • BlazorWebView backward compatibility host address
    • Addresses iOS 18 Blazor page rendering issue
    • Uses 0.0.0.1 instead of 0.0.0.0
    • Option to revert to the 0.0.0.0 as host
    • AppContext.SetSwitch("BlazorWebView.AppHostAddressAlways0000", true); in the MAUI startup pipeline (in MauiProgram.cs)
  • Compatibility package dependency is removed
  • MainPage is Obsolete
    • .NET MAUI is now a truly multi-window framework
    • Page is now associated with the Window
    • Pass the Page object as an argument to the Window constructor, or set the Page property accordingly
    • For further details, refer to this article
  • Frame is Obsolete
    • Use Border instead
    • Consult this article for further details
  • CollectionView & CarouselView improvements with a new opt-in Handler for iOS and Mac Catalyst
    • Improved Handler for better performance
    • Addresses Memory Leak issues
    • Refer to the code snippet at the end of this article
  • Revamped Native Embedding process
    • Overhauled methods for Native Embedding – UseMauiEmbeddedApp()
    • Window as a parameter in the window-aware overloaded method – ToPlatformEmbedded()
  • New Handler Disconnect policy
    • Better control over the Handler association
  • New TimeSelected event on the TimePicker control
    • Functions similar to the DateSelected event on the DatePicker control
    • The TimeChangedEventArgs provides the value of both the OldTime and the NewTime
  • New ProcessTerminated event on the WebView Control
    • Take control of the WebView
  • New Lifecycle methods for Remote Notifications on iOS and Mac Catalyst
    • Respond to notifications
  • Xcode Sync for CLI and VS Code
    • Tooling improvements
  • Justify option for HorizontalTextAlignment
    • Better UX
  • Behaviors no longer automatically inherit the BindingContext of their parent (a major shift from Xamarin.Forms)
    • Consult this article for further details

Apple Xcode Support:

Note: Apple Xcode 16 preview support is coming with .NET 9 RC2. The official release will be in November along with .NET 9 release. Support is now available on the .NET 8 stable channel. For further details, refer to this article.

Update: .NET 9 preview support for Apple Xcode 16 is now available. Update to RC2.

Apple Xcode 15.4 does not support macOS 15 (Sequoia). Consequently, it is advisable to refrain from upgrading your macOS development machines until .NET 9 is GA.

Handler Configuration:

CollectionView and CarouselView Handler opt-in in the MAUI startup pipeline (in MauiProgram.cs)

#if IOS || MACCATALYST
builder.ConfigureMauiHandlers(handlers =>
{
    handlers.AddHandler<Microsoft.Maui.Controls.CollectionView, Microsoft.Maui.Controls.Handlers.Items2.CollectionViewHandler2>();
    handlers.AddHandler<Microsoft.Maui.Controls.CarouselView, Microsoft.Maui.Controls.Handlers.Items2.CarouselViewHandler2>();
});
#endif

Tall TitleBar:

.NET MAUI 9 - Tall TitleBar
.NET MAUI 9 – Tall TitleBar – Host Controls on the TitleBar

Further Reading:

Happy coding. Stay connected as we continue to learn and share the experiences from this exciting journey of being a .NET developer.

Discover more from Developer Thoughts

Subscribe now to keep reading and get access to the full archive.

Continue reading