diff --git a/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs b/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
index 41cb6effa3..c2fe4a62e8 100644
--- a/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
+++ b/src/Uno.Extensions.Maui.UI/MauiEmbedding.cs
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Maui.ApplicationModel;
+using Microsoft.Maui.Hosting;
using Uno.Extensions.Hosting;
namespace Uno.Extensions.Maui;
@@ -9,15 +10,6 @@ namespace Uno.Extensions.Maui;
///
public static partial class MauiEmbedding
{
- ///
- /// Registers Maui embedding in the Uno Platform app builder.
- ///
- /// The updated app builder.
- /// The IHost builder.
- /// Optional lambda to configure the Maui app builder.
- public static IApplicationBuilder UseMauiEmbedding(this IApplicationBuilder builder, Action? configure = null) =>
- builder.UseMauiEmbedding(configure);
-
///
/// Registers Maui embedding in the Uno Platform app builder.
///
@@ -52,10 +44,12 @@ public static IHostBuilder UseMauiEmbedding(this IHostBuilder builder, Microsoft
/// Optional lambda to configure the Maui app builder.
public static IHostBuilder UseMauiEmbedding(this IHostBuilder builder, Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null)
where TApp : MauiApplication
- {
- app.UseMauiEmbedding(window, configure);
- return builder;
- }
+ => builder.ConfigureServices(services =>
+ {
+ // Expose the MauiApp to the Uno app via the IHost.Services
+ var mauiApp = app.UseMauiEmbedding(window, configure);
+ services.AddSingleton(mauiApp);
+ });
///
/// Registers Maui embedding with WinUI3 and WPF application builder.
@@ -63,16 +57,7 @@ public static IHostBuilder UseMauiEmbedding(this IHostBuilder builder, Mic
/// The Uno app.
/// The Main Application Window.
/// Optional lambda to configure the Maui app builder.
- public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null) =>
- app.UseMauiEmbedding(window, configure);
-
- ///
- /// Registers Maui embedding with WinUI3 and WPF application builder.
- ///
- /// The Uno app.
- /// The Main Application Window.
- /// Optional lambda to configure the Maui app builder.
- public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null)
+ public static MauiApp UseMauiEmbedding(this Microsoft.UI.Xaml.Application app, Microsoft.UI.Xaml.Window window, Action? configure = null)
where TApp : MauiApplication
{
#if MAUI_EMBEDDING
@@ -100,9 +85,8 @@ public static Microsoft.UI.Xaml.Application UseMauiEmbedding(this Microsof
};
#endif
-
#endif
- return app;
+ return mauiApp;
}
#if MAUI_EMBEDDING