WPF Application Shuts Down if I open a window and close it, but if I open no windows it stays running until I explicitly close it. Here is a quick sample application:
public partial class App : Application
{
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Count() != 0)
{
var mw = new MainWindow();
mw.ShowDialog();
}
}
}
If you supply this app a command-line argument it will open a window and close down as soon as you close the window; if you don’t supply an argument it will not close and must be killed via task manager.
Check http://msdn.microsoft.com/en-us/library/system.windows.application.shutdownmode.aspx.
The default shutdown mode is OnLastWindowClose.