As of Silverlight 3, Silverlight supports merged resource dictionaries. A merged resource dictionary enables you to declare the contents of a resource dictionary by referencing an external file. Also, merged resource dictionaries modify two of the characteristics of resource dictionaries: the lookup sequence, and key uniqueness requirements.
To declare a merged resource dictionary, you add a property element for the MergedDictionaries property to an existing ResourceDictionary location (typically FrameworkElement..::.Resources but sometimes Application..::.Resources). You must explicitly declare ResourceDictionary as an object element in order to use a property element within it. The existing ResourceDictionary may have other keyed resources as well as the MergedDictionaries property element. The content of MergedDictionaries is another ResourceDictionary declared as an object element. But this ResourceDictionary should not have further keyed resources as its own content, and it should declare only one attribute: Source. You can specify more than one ResourceDictionary within MergedDictionaries.
For example, the following XAML defines a ResourceDictionary with one keyed resource, as well as a MergedDictionaries collection that references two different resource dictionaries by URI:
<Grid>
<Grid.Resources>
<ResourceDictionary>
<SolidColorBrush Color="#d0157820" x:Key="muddyBrush"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/rd1.xaml">
<ResourceDictionary Source="/rd2.xaml">
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
....
<Grid>
In terms of the lookup sequence, a MergedDictionaries dictionary is checked only after checking all the keyed resources of the ResourceDictionary that declared MergedDictionaries. Then, each of the dictionaries within MergedDictionaries is checked, in the inverse of the order that they are declared within the MergedDictionaries property. In other words, the retrieval logic from within the collection of merged resource dictionaries is last in, first out.
Within the scope of the ResourceDictionary, the dictionaries are checked for key uniqueness. However, that scope does not extend across MergedDictionaries boundaries. For instance, you could define the same string key of muddyBrush for different resources if you declared the key once in the outer ResourceDictionary, and then again within any of the resource dictionaries that the same ResourceDictionary references by source as merged resource dictionaries. Within MergedDictionaries , if the key is found in the primary resource dictionary, the lookup stops there. Otherwise, each subsequently declared dictionary in MergedDictionaries is checked, with the last added merged dictionary checked first. If this also fails, then lookup falls through to the next FrameworkElement..::.Resources scope up toward the XAML root of the page, and thence to Application..::.Resources.
You can use the combination of the lookup sequence and lack of unique key enforcement across merged dictionary scopes to create a fallback sequence for resources. For instance, you might store user preferences for a particular brush color in the last merged resource dictionary in the sequence. But if no user preferences exist yet, you could define that same keyed resource in the preceding merged resource dictionary, and it could serve as the fallback.