InitializeComponent is a method defined on the System.Windows.Markup.IComponentConnector interface and used to load a compiled component page.
Below is the MSDN snippet below the link , which has more information:
IComponentConnector used internally by Baml2006Reader .
InitializeComponent implementations are widely observed as part of the infrastructure provided by infrastructures or technologies that use XAML in conjunction with application and programming models. For example, whenever you look at the generated classes for XAML root elements in WPF pages and applications, you will see the InitializeComponent defined in the output. This method also exists in the compiled assembly and plays a role in the WPF application model for loading the contents of the XAML user interface during XAML parsing (and I suppose, therefore, the InitializeComponent must be in the interface and be publicly available so that other external WPF-related assemblies can use it )
To explain this further, go to the definition of the InitializeComponent() method in your (say): Window1.g.cs class say: WPFProject project and change its access from public to private
(save the .g.cs file in your project, otherwise the build process overrides this file and you will not be able to see the error)
Now, when you compile your WPF project, it throws a compilation error, as shown below:
Error 22 'WPFProject.Window1' does not implement the member of the 'System.Windows.Markup.IComponentConnector.InitializeComponent ()' interface. 'WPFProject.Window1.InitializeComponent ()' cannot implement an interface member because it is not public.
In addition, InitializeComponent() marked with the [System.Diagnostics.DebuggerNonUserCodeAttribute()] attribute, so you cannot enter this method during debugging.
There is another SO QA discussion that will help you explain in more detail.
VS1
source share