Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF application without a window loading automatically

$
0
0

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. However I then decided I needed a window and added another one. 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. 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(); } } }

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();
        }
    }
}



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>