将XAML控件从WPF应用程序复制到类库后的问题 [英] Problems after copying XAML controls from WPF Application to a class library

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

问题描述

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

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

图书馆项目文件无法指定ApplicationDefinition元素.

Library project file cannot specify ApplicationDefinition element.

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

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应用程序复制到类库后的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆