Example #1
0
 static void Main(string[] args)
 {
     var app = new App();
     var window = new MainWindow();
     window.Show();
     app.Run(window);
 }
Example #2
0
        //  The following code infrastructure is created and run to start the application but not shown
        //        public App() { }

        //        [STAThread]  // attribute is required for WPF applications
        //        public static void Main() {
        //            // Create new instance of application subclass
        //            App app = new App();

        //            app.InitializeComponent();

        //          an optional Splash screen can be started here http://msdn.microsoft.com/en-us/library/cc656886.aspx

        //            // Start running the application
        //            app.Run();
        //        }

        //        public void InitializeComponent()  {
        // Code is auto-generated to register events and set properties that were 
        //  defined in XAML in the application definition 
        // ...
        //        }

        /// <summary>
        /// Handles the Startup event signifying the Application is now running.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="StartupEventArgs" /> instance containing the event data.</param>
        private void App_Startup(object sender, StartupEventArgs e) {
            // Process command line args
            // IMPROVE For more robust command line processing approach, see http://msdn.microsoft.com/en-us/library/aa972153(v=vs.90).aspx

            // The singleton instance of App or Application can be acquired once the Application.Startup event has been received
            // App instance = (App)Application.Current;
            // Application instance = Application.Current;

            // Create main application window
            MainWindow mainWindow = new MainWindow();
            mainWindow.Show();
        }