开发者

How is WPF startup with App.xaml/cs and MainWindow.xaml/cs

Suppose we start from the default new WPF project with App.xaml/cs, MainWindow.xaml/cs. What's the order the application execute these codes.

  1. Parse App.xaml
  2. Run App.xaml.cs
  3. Parse MainWindo开发者_如何学Pythonw.xaml
  4. Run MainWindow.xaml.cs?

And how about the execution of Resource.Designer.cs and Settings.Designer.cs in Properties?


Every .NET application (PE files) start with an entry point which is generally "Main" but in WPF you can't see this because Visual Studio hides it from the user as it is quite messy code.

You'll know yourself the execution flow once you find the Main method. For that look at the following image:

How is WPF startup with App.xaml/cs and MainWindow.xaml/cs


As Int3 user says, the Main method is located at App.g.cs and goes like this

public static void Main() {
    YourAppNamespace.App app = new YourAppNamespace.App();
    app.InitializeComponent();
    app.Run();
}

Which means you'll get the App constructor executed before anything else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜