tags:

views:

16

answers:

2

I ask because if you create a new WPF project in VS 2008 the default generated code is:

public partial class Window1 : Window
{
    public Window1()
    {
        InitializeComponent();
    }
}

However, commenting out the call to InitializeComponent does not prevent the application running.

Why is this?

+1  A: 

While the window will load up, you won't be able to use events or access the XAML from the code behind if you don't call InitializeCmponent.

Here is a good explanation

mdm20
A: 

Just right click the InitializeComponent call, then go to definition.

You'll see that the definition of InitializeComponent is just an XAML parser. Vital to load your WPF window and everycomponent in it. You can compare it with converting an XSD document to a CS or VB Class. Not necessary but pretty useful.

Maarten Van Genechten