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リソースディクショナリを参照します。
含まれているリソースディクショナリだけでなく、他のコントロールからブラシを参照できます。
なぜ参照できないのか、またはマージされたリソースディクショナリの階層の上位にあるリソースへの参照を解決しないのですか?ここで何が欠けていますか?