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

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

This is very strange.

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



        
相关标签:
14条回答
  • 2020-12-16 09:48

    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.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题