Reputation: 1397
I have a control that has a lot of themes and each theme is represented by a ResourceDictionary. The problem is that the dictionaries are almost identical and they differ only in the beggining where I have declared color brushes, for example:
<SolidColorBrush x:Key="FirstRd1" Color="#3F555555" />
<SolidColorBrush x:Key="SecondRd1" Color="#00000000" />
<SolidColorBrush x:Key="ThirdRd1" Color="#FF333333" />
<SolidColorBrush x:Key="FourthRd1" Color="#FF000000" />
These brushes (and other xaml objects for style) are used here and there on the same place, like this:
<!-- ResourceDictionary 1 -->
<Border CornerRadius="4"
Margin="0, 0, 0, 0"
BorderThickness="1"
BorderBrush="{StaticResource FirstRd1}">
<!-- Some content -->
</Border>
<!-- ResourceDictionary 2 -->
<Border CornerRadius="4"
Margin="0, 0, 0, 0"
BorderThickness="1"
BorderBrush="{StaticResource FirstRd2}">
<!-- Some content -->
</Border>
How to move the same elements with different brush like above in a single file? There are aslo other elements that do not depend on the brushes, but they are nested or have nested dependant controls. What will be the best solution in this situation, as I do not want to edit 15+ files for a single dummy change?
Upvotes: 1
Views: 1351
Reputation: 51329
You can merge resource dictionaries. Declare your common stuff in one file, then for the differentiated parts make each one it's own file and merge it with the common file.
See http://msdn.microsoft.com/en-us/library/aa350178.aspx
Upvotes: 1