Explicit Application Creation

Example 2-1 shows code for creating an instance of the Application class.

Example 2-1. Creating an application explicitly using System;

using System.Windows; // the home of the Application class class Program { [STAThread] static void Main() {

Application app = new System.Windows.Application();

Window1 window = new Window1(); window.Show( ); app.Run();

Here, we're creating an application inside an STA thread,* creating a window and showing it, and then running the application. While the application is running, WPF processes Windows messages and routes events to WPF UI objects as necessary. When the Run method returns, messages have stopped being routed and generally don't start again (unless you show a modal window after the Run method returns, but that's not something you'll usually do). During its lifetime, the application provides various services.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment