I have set up a WPF application so that it does not load a window automatically by modifying the app.xaml.cs as shown below and by setting the build action to Page. I have also removed the starturl from the app.xaml. I have introduced a controller class from where the application starts as you can see in the code below and in the constructor for the controller I have created and opened a new window. I deleted the original MainWindow which was produced automatically when opening the application.
Anyway the problem is that after opening the new window that I have added in the controller I then close the window and the Application terminates? Why? I don't want the application to terminate and I don't understand why it is terminating on closing the window. Or to put it another way how can I introduce a window that doesn't cause the application to terminate on closing the window? Any help greatly appreciated.
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace UserTraining
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
App()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
App app = new App();
UserTrainingController control = new UserTrainingController();
app.Run();
}
}
}
UserTrainingController class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace UserTraining
{
class UserTrainingController
{
public UserTrainingController()
{
IntroductionWindow w = new IntroductionWindow();
w.Show();
}
}
}