Problems after copying XAML controls from WPF Application to a class library

后端 未结 5 1439
南笙
南笙 2021-02-04 23:50

In the process of refactoring some code, I encountered several build errors such as these:

Library project file cannot specify ApplicationDefinition element.

5条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 00:02

    When you copy and paste files either within a project or to another project, Visual Studio has a nasty habit of not keeping the same BuildAction property. It often changes the build action to a seemingly random value, e.g. ApplicationDefinition, which causes that build error.

    Check (in the Visual Studio properties window with the file selected in the Solution Explorer) that each of your .xaml files have a BuildAction property of Page and your code files have a BuildAction property of Compile.

提交回复
热议问题