将XAML控件从WPF应用程序复制到类库后的问题

将XAML控件从WPF应用程序复制到类库后的问题

本文介绍了将XAML控件从WPF应用程序复制到类库后的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在重构某些代码的过程中,我遇到了一些构建错误,例如:

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

项目文件包含无效的属性值.

The project file contains a property value that is not valid.

如何解决这些错误?

推荐答案

当您将文件复制并粘贴到一个项目中或另一个项目中时,Visual Studio有一个讨厌的习惯,就是不保持相同的 BuildAction >属性.它通常会将构建操作更改为看似随机的值,例如 ApplicationDefinition ,这会导致生成错误.

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.

检查(在Visual Studio属性窗口中,在解决方案资源管理器中选择了文件),检查您的每个.xaml文件是否具有 Page BuildAction 属性以及您的代码文件具有编译 BuildAction 属性.

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.

这篇关于将XAML控件从WPF应用程序复制到类库后的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:16