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

前端 未结 14 1319
失恋的感觉
失恋的感觉 2020-12-16 08:49

This is very strange.

I have an XAML file that looks as follows...



        
14条回答
  •  旧巷少年郎
    2020-12-16 09:49

    So simple, but so easy to overlook: MainWindow's x:Class was set to "MainWindow", when it should have been set to namespace.MainWindow (x:Class="namespace.MainWindow"). If this is not done, then the MainWindow.g.xaml file will not include a namespace block, and the call to InitializeComponent() in MainWindow's constructor will not work.

    Although this obviously isn't a solution to willem's problem, I posted it here because there are so many other solutions listed. Hopefully this will help someone else who stumbles on this post when trying to fix their problem.

提交回复
热议问题