in my wpf application,i want to show login form at sturtup and if user enter a valid username and password, window1 will be displayed. i user this code in my app.xmal :
<Application x:Class="Acountant.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
and this code in app.xmal.cs :
private void Application_Startup(object sender, StartupEventArgs e)
{
LoginFRM f = new LoginFRM();
if (f.ShowDialog() == true)
{
var frm = new Window1();
frm.ShowDialog();
}
}
but my Application closed!
You should set Application.ShutdownMode
to OnExplicitShutdown
(msdn).
Example:
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
ShutdownMode="OnExplicitShutdown"
>
</Application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With