错误:属性“资源”只能设置一次 [英] Error: The property "Resources" can only be set once
问题描述
我知道有 $ b此论坛上的RC和
Silverlight论坛中的$ ba类似帖子 / a>。
我使用的是EB Version 4.0.20901.0。对于WPF(不是Silverlight)应用程序,我在app.xaml中得到以下代码块的错误:
I am using EB Version 4.0.20901.0. for a WPF (not Silverlight) application and I get the error for the following block of code in app.xaml:
<Application.Resources>
<ResourceDictionary Source="BureauBlack.xaml"/>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="LightGray"/>
</Style>
</Application.Resources>
推荐答案
嗯,完全违背我原来的想法,EB是正确的,VS2010是错误的。
Well, completely contrary to my original thought, EB is correct and VS2010 is wrong.
是的,一切看起来都很完美,应用程序可能是bu在VS2010中没有任何错误,但是一旦运行应用程序,就会出现错误 - "'资源'属性已经在'应用'上设置了......"。
Yes, everything looked perfect and the application could be built without any error in VS2010, but once the application is run, an error occurs - "''Resources' property has already been set on 'App'...".
通过将样式块放到资源文件(Style.xaml)并将上述代码更改为以下代码已得到纠正:
It has been corrected by putting the Style block to a resource file (Style.xaml) and changing the aforementioned code to the following:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="BureauBlack.xaml"/>
<ResourceDictionary Source="Style.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
这篇关于错误:属性“资源”只能设置一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!