i have a WPF Application with a LoginWindow to access,so i create a Splash Screen for this Login window as follow :
– in App.xaml
< Application x:Class="WPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup"
/>
–in App.xaml.cs:
private void Application_Startup(object sender, StartupEventArgs e)
{
Login login = new Login();
login.Show();
}
–and in Login.xaml.cs if the log in is succesful :
PrimaryWindow mainWindow= new PrimaryWindow ();
Application.Current.MainWindow = mainWindow;
this.Close();
mainWindow.Show();
.This code is right but sincerely with my poor knowledge i don’t know that’s a good method to apply for a Login Window or not and i don’t know if this method can be “dangerous” for my application that store data from a database and has many features , so i ask you if my way is good or not and if you have a better way can you suggest or show me that?
Thanks for your attention.
Have a lucky day.
I would handle this with 2 windows and an Application_Startup method. Here is what my app (which has a similar login idea) looks like:
This allows the user to close the application simply by closing the login window (i.e. not logging in at all) or by closing the main window AFTER they have used it for a while.