在 Visual Studio 2013 中使用 WPF 时,我遇到了一个错误:
错误 2 多次设置属性“内容”。
错误1 属性“Content”只能设置一次
现在,首先。我向 google 查找错误消息,并得到了链接到 StackOverflow 的热门结果。
XAML - 属性“内容”设置多次 https://stackoverflow.com/questions/14868713/xaml-the-property-content-is-set-more-than-once
属性“内容”被设置多次 https://stackoverflow.com/questions/1331456/the-property-content-is-set-more-than-once
属性内容被设置多次 https://stackoverflow.com/questions/10384395/property-content-is-set-more-than-once
包括 MSDN 帖子:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/686be076-954f-4373-a2e6-fc42a6a27718/error-the-property-content-is-set-more-than-once?forum=工作组 http://social.msdn.microsoft.com/Forums/vstudio/en-US/686be076-954f-4373-a2e6-fc42a6a27718/error-the-property-content-is-set-more-than-once?forum=wpf
虽然被提出信息丰富的基于原始海报代码的定制解决方案集合,我还没有遇到一个实际的基本解决方案,详细说明此错误的原因(XAML 新手),同时这可能是多个报告问题的重复。我个人宁愿避免发布有问题的代码以获得量身定制的解决方案。我更愿意来到这里向社区询问为什么新手 XAMP/WPF 开发人员可能会遇到这个应用程序和解决方案,而不是太多顶级的最佳实践。更多 WPF/XAMP 开发人员关于如何轻松识别解决方案并在未来继续进一步的调试步骤的建议
为了论证:
<Window x:Class="WPFT.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="197.198" Width="427.95">
<TextBlock>Hello</TextBlock>
<TextBlock>World</TextBlock>
</Window>