WPF Error when implementing Login.xaml
- by LnDCobra
I am getting the following exception:
"Nullable object must have a value"
Everything was working when I was using
StartupURI="MainWindow.xaml"
but I wanted to implement a login screen so I changed this to
Startup="Application_Startup"
and then created the following method in App.xaml.cs:
private void Application_Startup(object sender, StartupEventArgs e)
{
UpdateAccounts();
bool result = true;
///*
LoginWindow login = new LoginWindow();
result = login.ShowDialog().Value;
/* */
if (!result)
{
return;
}
MainWindow window = new MainWindow();
bool main = window.ShowDialog().Value;
}
Does anyone have any idea what is going on? Or any suggestions on what is the best practice for implementing login interface.