From 7310dd58c69c97911481aa7099e529c739b0975b Mon Sep 17 00:00:00 2001 From: eriklimakc Date: Mon, 9 Dec 2024 15:44:05 +0000 Subject: [PATCH] fix: Navigate once when starting app --- .../FrameworkElementExtensions.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Uno.Extensions.Navigation.UI/FrameworkElementExtensions.cs b/src/Uno.Extensions.Navigation.UI/FrameworkElementExtensions.cs index 92d75cf747..30cb4beb48 100644 --- a/src/Uno.Extensions.Navigation.UI/FrameworkElementExtensions.cs +++ b/src/Uno.Extensions.Navigation.UI/FrameworkElementExtensions.cs @@ -33,9 +33,8 @@ public static Task HostAsync( var nav = elementRegion.Navigator(); if (nav is not null) { - var initialNavigation = () => nav.NavigateRouteAsync(root, initialRoute ?? string.Empty); - var start = () => Task.CompletedTask; + var hostConfigOptions = sp.GetService>(); if (hostConfigOptions?.Value is { } hostConfig && hostConfig.LaunchRoute() is { } launchRoute && @@ -55,12 +54,18 @@ public static Task HostAsync( { start = () => nav.NavigateViewModelAsync(root, initialViewModel); } + else + { + start = () => nav.NavigateRouteAsync(root, initialRoute ?? string.Empty); + } + var fullstart = async () => { - await initialNavigation(); await start(); }; + var startupTask = elementRegion.Services!.Startup(fullstart); + return startupTask; } return Task.CompletedTask;