From 16495770ba064ce618c3587b5fa14bc06a85eba8 Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Sun, 5 Jul 2026 01:29:56 -0500 Subject: [PATCH] Load target view's data before transitioning --- LANCommander.Launcher/Services/NavigationService.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/LANCommander.Launcher/Services/NavigationService.cs b/LANCommander.Launcher/Services/NavigationService.cs index 84428ca0..f7e587ca 100644 --- a/LANCommander.Launcher/Services/NavigationService.cs +++ b/LANCommander.Launcher/Services/NavigationService.cs @@ -49,17 +49,17 @@ public partial class NavigationService : ObservableObject, INavigationService } // Show the loading overlay and yield so the UI thread can paint it - // BEFORE the heavy view creation from the ContentControl DataTemplate. + // over the CURRENT view before we do any heavy work. IsNavigating = true; await Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Render).GetTask(); - CurrentView = viewModel; - try { if (initializeAsync != null) await initializeAsync(); + CurrentView = viewModel; + // Yield again so the new view finishes layout/render // before we hide the overlay. await Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Background).GetTask(); @@ -67,6 +67,8 @@ public partial class NavigationService : ObservableObject, INavigationService catch { // Initialization errors are handled by the caller's callback. + // Still swap to the target view so navigation isn't left stuck. + CurrentView = viewModel; } finally {