0

I have a base styles files that contains all by base colors and base font settings. Then I have 2 other resource dictionaries that use that the initial resource.

I have it setup as follows:

<Application.Resources>
    <ResourceDictionary>
        <localization:LocalizationLocator x:Key="LocalizedStrings" />
        <viewModels:ViewModelLocater x:Key="VmLocator" />
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="\Resources\Styles\BaseStyles.xaml" />
            <ResourceDictionary Source="\Resources\Styles\FormInputStyles.xaml" />
            <ResourceDictionary Source="\Resources\Styles\OtherControllsStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

Then I get the following exception from FormInputStyles.xml

Cannot find a Resource with the Name/Key MyNewAccentColor [Line: 17 Position: 44]

Is there a way to load the BaseStyles.xaml before adding merged dictionaries?

(I know I could have them all in the same file but I would like my styles broken down so that I can have better code re-use)

Rolf Wessels
  • 797
  • 9
  • 12

1 Answers1

0

I've not tried this myself, but MSDN page says:

If multiple merged dictionaries exist, these dictionaries are checked in the inverse of the order in which they are declared in the MergedDictionaries property.

I.e. try to put BaseStyles.xaml as last element.

And please also check this SO question: Proper usage of Merged Resource Dictionaries in Silverlight 3

Community
  • 1
  • 1
Haspemulator
  • 11,050
  • 9
  • 49
  • 76