restores the legacy behavior
This commit is contained in:
parent
01bc4782a0
commit
404bba56ab
3 changed files with 13 additions and 17 deletions
|
|
@ -65,7 +65,10 @@ public partial class App : Application
|
||||||
singleViewPlatform.MainView = CreateMainWindow();
|
singleViewPlatform.MainView = CreateMainWindow();
|
||||||
ApplyDarkMode(settings);
|
ApplyDarkMode(settings);
|
||||||
}
|
}
|
||||||
|
var mainVm = ServiceProvider!.GetRequiredService<HomePageViewModel>();
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
this.PushPageAsync(mainVm).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,9 +89,6 @@ public partial class App : Application
|
||||||
PushMainPageAsync().Wait();
|
PushMainPageAsync().Wait();
|
||||||
};
|
};
|
||||||
|
|
||||||
var homeVm = ServiceProvider!.GetRequiredService<HomePageViewModel>();
|
|
||||||
|
|
||||||
this.PushPageAsync(homeVm).Wait();
|
|
||||||
Window.SessionBanner.DataContext = sessionStatus;
|
Window.SessionBanner.DataContext = sessionStatus;
|
||||||
return Window;
|
return Window;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,4 +74,4 @@ public static class ServiceCollectionHelpers
|
||||||
|
|
||||||
return services.BuildServiceProvider();
|
return services.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,6 @@ namespace PostIt;
|
||||||
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
|
Url = "https://docs.avaloniaui.net/docs/concepts/view-locator")]
|
||||||
public class ViewLocator : IDataTemplate
|
public class ViewLocator : IDataTemplate
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider _services;
|
|
||||||
|
|
||||||
public ViewLocator(IServiceProvider services)
|
|
||||||
{
|
|
||||||
_services = services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Control Build(object? data)
|
public Control Build(object? data)
|
||||||
{
|
{
|
||||||
|
|
@ -38,15 +32,17 @@ public class ViewLocator : IDataTemplate
|
||||||
|
|
||||||
private Control BuildCore(object? data)
|
private Control BuildCore(object? data)
|
||||||
{
|
{
|
||||||
|
var app = App.Current as App;
|
||||||
|
var services = app!.ServiceProvider!;
|
||||||
return data switch
|
return data switch
|
||||||
{
|
{
|
||||||
MainViewModel => _services.GetRequiredService<MainPage>(),
|
MainViewModel => services.GetRequiredService<MainPage>(),
|
||||||
Settings => _services.GetRequiredService<SettingsPage>(),
|
Settings => services.GetRequiredService<SettingsPage>(),
|
||||||
HomePageViewModel => _services.GetRequiredService<HomePage>(),
|
HomePageViewModel => services.GetRequiredService<HomePage>(),
|
||||||
SignaturePageViewModel => _services.GetRequiredService<SignaturePage>(),
|
SignaturePageViewModel => services.GetRequiredService<SignaturePage>(),
|
||||||
AddCircleMemberDialogViewModel => _services.GetRequiredService<AddCircleMemberDialog>(),
|
AddCircleMemberDialogViewModel => services.GetRequiredService<AddCircleMemberDialog>(),
|
||||||
CirclesPageViewModel => _services.GetRequiredService<CirclesPage>(),
|
CirclesPageViewModel => services.GetRequiredService<CirclesPage>(),
|
||||||
PostAclDialogViewModel => _services.GetRequiredService<PostAclDialog>(),
|
PostAclDialogViewModel => services.GetRequiredService<PostAclDialog>(),
|
||||||
null => new TextBlock { Text = "No view for <null>" },
|
null => new TextBlock { Text = "No view for <null>" },
|
||||||
_ => new TextBlock { Text = $"No view for {data.GetType().Name}" }
|
_ => new TextBlock { Text = $"No view for {data.GetType().Name}" }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue