【发布时间】:2012-02-29 06:47:58
【问题描述】:
我的 App.xaml 中有以下代码集:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Client.Common;component/Theme/Brushes.xaml"/>
<ResourceDictionary Source="/Client.Common;component/Theme/Fonts.xaml"/>
<ResourceDictionary Source="/Client.Common;component/Theme/CoreStyles.xaml"/>
<ResourceDictionary Source="/Client.Common;component/Theme/SdkStyles.xaml"/>
<ResourceDictionary Source="/Client.Common;component/Theme/MyAppName.xaml"/>
<ResourceDictionary Source="/Client.Common;component/Controls/NavigationPanel.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
NavigationPanel.xaml 包含如下样式:
<Style x:Key="NavigationPanelListBox" TargetType="ListBox">
<Setter Property="Background" Value="{StaticResource DarkBackground}" />
<Lots of XAML>
</Style>
{StaticResource DarkBackground} 在 Brushes.xaml 文件(即第一个资源字典)中定义。它被定义为
<SolidColorBrush x:Key="DarkBackground" Color="#FF707176" />
在资源字典中。
在运行时,我收到以下错误:
Cannot find a Resource with the Name/Key DarkBackground [Line: 16 Position: 44]
行号和位置引用app.xaml中的NavigationPanel.xaml资源字典。
我可以从其他控件引用画笔,但不能引用包含的资源字典。
为什么我不能引用或为什么不能解析对合并资源字典层次结构中更高资源的引用?我在这里错过了什么?
【问题讨论】:
标签: c# silverlight xaml resourcedictionary mergeddictionaries