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

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

This is very strange.

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



        
14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 09:31

    I had the same problem with a Visual Studio 2010 sample project that I manually reverted to Visual Studio 2008. I found I had forgotten to set the Target Framework of the project to .NET Framework 3.5. It was empty in the project reverted to Visual Studio 2008, initially set to 4.0 in the original Visual Studio 2010 project.

    To set Target Framework of a project, go to project properties, access the first tab called Application, and select .NET Framework 3.5 in the Target Framework dropdown.

    Of course, I'd prefer Visual Studio giving me an error or at least a warning that I had not set my Target Framework, but hey, that's part of developing in Visual Studio, I guess.

    Visual Studio 2008 WPF project properties

提交回复
热议问题