Sheen Space

Start-up process of WPF application

leave a comment »


This is my WPF study note. I don’t guarantee it is error-free. Please kindly post comment when you think anything is wrong.

There is a top-level user-defined application class derived from System.Windows.Application. Let’s call it MyApp. After compilation, C# compiler generates two functions for MyApp class:

  • static void Main()
  • void  InitializeComponent()

Compiler prohibits you from defining the same functions.

MyApp.Main() calls MyApp.InitializeComponent(), and then calls System.Windows.Application.Run().

MyApp.InitializeComponent() has information of XAML file of main window of the application, and calls System.Windows.Application::set_StartupUri() with the XAML file path. It knows the XAML file path of main window because the file path is specified in <Application/StartupUri> in MyApp.xaml.

System.Windows.Application.Run() executes like normal WinForm code, initialising the main window and entering window message loop.

Advertisements

Written by Ying

23/05/2012 at 00:09

Posted in DotNet, Technology, Windows

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: