show the window

This commit is contained in:
Paul Schneider 2026-08-24 00:30:29 +01:00
commit 88e1499e4b
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
2 changed files with 8 additions and 6 deletions

View file

@ -47,7 +47,7 @@ public partial class App : Application
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{ {
desktop.MainWindow = CreateMainWindow(); desktop.MainWindow = Window = CreateMainWindow();
ApplyDarkMode(settings); ApplyDarkMode(settings);
} }
else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime) else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime)
@ -57,12 +57,13 @@ public partial class App : Application
{ {
Window = CreateMainWindow(); Window = CreateMainWindow();
ApplyDarkMode(settings); ApplyDarkMode(settings);
Window.Show();
return Window; return Window;
}; };
} }
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform) else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{ {
singleViewPlatform.MainView = CreateMainWindow(); singleViewPlatform.MainView = Window = CreateMainWindow();
ApplyDarkMode(settings); ApplyDarkMode(settings);
} }
var mainVm = ServiceProvider!.GetRequiredService<HomePageViewModel>(); var mainVm = ServiceProvider!.GetRequiredService<HomePageViewModel>();

View file

@ -10,7 +10,8 @@ public static class ViewModelBaseHelpers
{ {
public static async Task PushPageAsync(this App app, ViewModelBase vm) public static async Task PushPageAsync(this App app, ViewModelBase vm)
{ {
if (app.Window is null) var window = app.Window;
if (window is null)
{ {
throw new InvalidOperationException("MainWindow is not initialized yet."); throw new InvalidOperationException("MainWindow is not initialized yet.");
} }
@ -39,12 +40,12 @@ public static class ViewModelBaseHelpers
page.DataContext = vm; page.DataContext = vm;
// Avoid stacking the same singleton page twice (e.g. SettingsPage). // Avoid stacking the same singleton page twice (e.g. SettingsPage).
var stack = app.Window.NavRoot.NavigationStack; var stack = window.NavRoot.NavigationStack;
if (stack.Count > 0 && ReferenceEquals(stack[stack.Count - 1], page)) if (stack.Count > 0 && ReferenceEquals(stack[stack.Count - 1], page))
{ {
return; return;
} }
await app.Window.NavRoot.PushAsync(page); await window.NavRoot.PushAsync(page);
} }
} }