Here's a summary of what's new in .NET MAUI, .NET for Android, and .NET for iOS, Mac Catalyst, macOS, and tvOS in this preview release:
.NET MAUI updates in .NET 10:
- What's new in .NET MAUI in .NET 10 documentation.
In your projects you can now glob together XML-namespaces into a new global namespace xmlns="http://schemas.microsoft.com/dotnet/maui/global", and use them without prefixes. The .NET MAUI namespace is included already.
By convention the new project template creates a file GlobalXmlns.cs.
[assembly: XmlnsDefinition(
"http://schemas.microsoft.com/dotnet/maui/global",
"MyApp.Views")]
[assembly: XmlnsDefinition(
"http://schemas.microsoft.com/dotnet/maui/global",
"MyApp.Controls")]
[assembly: XmlnsDefinition(
"http://schemas.microsoft.com/dotnet/maui/global",
"MyApp.Converters")]
[assembly: XmlnsDefinition(
"http://schemas.microsoft.com/dotnet/maui/global",
"http://schemas.syncfusion.com/maui/toolkit")]You can then use anything in those namespaces like you do .NET MAUI controls, without prefix.
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/maui/global"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.MainPage">
<TagView x:DataType="Tag" />
</ContentPage>The x namespace cannot be globbed into the global namespace since it's used for parsing.
You can opt-in to this feature by adding the following to your project file. As of now, turning this on may cause errors to be reported by various XAML tools.
<PropertyGroup>
<DefineConstants>$(DefineConstants);MauiAllowImplicitXmlnsDeclaration</DefineConstants>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>With this change you can also eliminate xmlns and xmlns:x from XAML files.
<ContentPage x:Class="MyApp.MainPage">
<TagView x:DataType="Tag" />
</ContentPage>In this usage:
- the default xmlns is the global one
- the
x:prefix is added by default - all
xmlnswith aXmlnsPrefixare also accessible with their prefix, even if they are included in the globalxmlns. These are useful for disambiguating a name. For example, themaui:prefix points to the mauixmlns. - you still need to use the
x:prefix (e.g.x:Class,x:DataType), but you don't have to declare it
The HybridWebView now allows you to intercept when the browser requests a web resource in order to take action before it executes, such as adding a header to the request. The do this, add a listener to the WebResourceRequested event.
<HybridWebView WebResourceRequested="HybridWebView_WebResourceRequested" />private void HybridWebView_WebResourceRequested(object sender, HybridWebViewWebResourceRequestedEventArgs e)
{
// NOTES:
// * This method MUST be synchronous, as it is called from the WebView's thread.
// * This method MUST return a response (even if it is not yet complete), otherwise the
// WebView may freeze or return a error response.
// * The response must be set using the SetResponse method of the event args.
// Only handle requests for the specific image URL
if (!e.Uri.ToString().Contains("sample-image.png"))
return;
// Prevent the default behavior of the web view
e.Handled = true;
// Return the stream or task of stream that contains the content
// NOTE: the method is NOT awaited, the WebView will continue to load the content
e.SetResponse(200, "OK", "image/png", GetStreamAsync());
}This release was focused on quality improvements. A detailed list can be found on dotnet/android GitHub releases.
This release was focused on quality improvements. A detailed list can be found on dotnet/macios GitHub releases including a list of Known issues.
Thank you contributors! ❤️
@Ahamed-Ali, @Dhivya-SF4094, @HarishKumarSF4517, @KarthikRajaKalaimani, @LogishaSelvarajSF4525, @MartyIX, @NafeelaNazhir, @NanthiniMahalingam, @NirmalKumarYuvaraj, @PaulAndersonS, @PureWeen, @Shalini-Ashokan, @StephaneDelcroix, @SubhikshaSf4851, @SuthiYuvaraj, @SyedAbdulAzeemSF4852, @Tamilarasan-Paranthaman, @TamilarasanSF4853, @Vignesh-SF3580, @anandhan-rajagopal, @bhavanesh2001, @corvinsz, @devanathan-vaithiyanathan, @drasticactions, @jfversluis, @jonathanpeppers, @jsuarezruiz, @kubaflo, @mattleibow, @moljac, @nivetha-nagalingam, @pjcollins, @prakashKannanSf3972, @praveenkumarkarunanithi, @rmarinho, @simonrozsival, @tj-devel709