Scottintexas
Well-known member
I am being told by the error list that MainWindowView does not have a data context. And another error saying it does not have a Show method. It has in the past and I am stumped on how to locate the real issue.
Thanks for any help you can give me.
C#:
protected override async void OnStartup(StartupEventArgs e)
{
await AppHost!.StartAsync();
var startupForm = AppHost.Services.GetRequiredService<MainWindowView>();
//Two offending lines
startupForm.DataContext = AppHost.Services.GetRequiredService<MainWindowViewModel>();
startupForm.Show();
base.OnStartup(e);
}
public App()
{
AppHost = Host.CreateDefaultBuilder()
.ConfigureServices((HostBuilderContext, services) =>
{
//register services.
services.AddSingleton<MainWindowView>();
services.AddSingleton<MyLogger>();
services.AddSingleton<MainWindowViewModel>(serviceProvider =>
{
var paramVal = serviceProvider.GetRequiredService<MyLogger>();
return new MainWindowViewModel(paramVal);
});
})
.Build();
}
Thanks for any help you can give me.