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.
- Parse
App.xaml
- Run
App.xaml.cs
- Parse
MainWindo开发者_如何学Pythonw.xaml
- 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:
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.
精彩评论