#43 – What Happens in WPF Main() Function
August 24, 2010 4 Comments
When creating a new WPF standalone application using the New Project wizard in Visual Studio 2013, Visual Studio automatically creates a class that derives from System.Windows.Application, as well as a static Main() function that will be the first function called when the application is started.
Here’s how the main application object is defined:
public partial class App : Application
During the Main method, the application is started up by:
- Creating a new instance of the Application object
- Calling Application.InitializeComponent to constitute the application from App.xaml
- Calling Application.Run to start the application
public static void Main() { WpfApplication.App app = new WpfApplication.App(); app.InitializeComponent(); app.Run(); }