Why can't Visual Studio find my WPF InitializeComponent method?

One case I have seen this happening in when you copy paste an XAML control/window, etc. The InitializeComponent method exists in a corresponding .g.cs file that is automatically generated. In my case, after copy paste, Build Action for the XAML (in Properties window) was changed to "Resource". I changed it to "Page", and it started working fine.

I hope this helps.

The thread which helped me with this was The name 'InitializeComponent' does not exist....


Your XAML says:

x:Class="ix.Production.Title"

while the actual class is ix.Outage.Title. Either change the XAML declaration or move the class to the ix.Production namespace.