show the window
This commit is contained in:
parent
246111dee1
commit
88e1499e4b
2 changed files with 8 additions and 6 deletions
|
|
@ -47,7 +47,7 @@ public partial class App : Application
|
|||
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = CreateMainWindow();
|
||||
desktop.MainWindow = Window = CreateMainWindow();
|
||||
ApplyDarkMode(settings);
|
||||
}
|
||||
else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime)
|
||||
|
|
@ -57,12 +57,13 @@ public partial class App : Application
|
|||
{
|
||||
Window = CreateMainWindow();
|
||||
ApplyDarkMode(settings);
|
||||
Window.Show();
|
||||
return Window;
|
||||
};
|
||||
}
|
||||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
|
||||
{
|
||||
singleViewPlatform.MainView = CreateMainWindow();
|
||||
singleViewPlatform.MainView = Window = CreateMainWindow();
|
||||
ApplyDarkMode(settings);
|
||||
}
|
||||
var mainVm = ServiceProvider!.GetRequiredService<HomePageViewModel>();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ public static class ViewModelBaseHelpers
|
|||
{
|
||||
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.");
|
||||
}
|
||||
|
|
@ -39,12 +40,12 @@ public static class ViewModelBaseHelpers
|
|||
page.DataContext = vm;
|
||||
|
||||
// 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))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await app.Window.NavRoot.PushAsync(page);
|
||||
await window.NavRoot.PushAsync(page);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue