I am working on a WPF application where I by now have a lot of different Resource Dictionaries comprising a huge amount of styles. Many of those styles describe brush settings for borders, backgrounds, etc. Until now, every formatting is in a separate style.
However, what I would like to do (if possible) is to "group" different styles that belong together into a "parent" style - thereby being able to make it a little more manageable which styles concerns which controls.
For example, for a GroupBox, the settings would ideally be registered in a style like this:
<Style x:Key="GroupBoxFormat">
<Style.Resources>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="ElementGradientBrush">
<GradientStop Color="AntiqueWhite" Offset="0" />
<GradientStop Color="Tan" Offset=".7" />
</LinearGradientBrush>
<Border x:Key="BorderFormat" BorderThickness="2">
<Border.Background>
<SolidColorBrush Color="Gold"></SolidColorBrush>
</Border.Background>
<Border.BorderBrush>
<SolidColorBrush Color="Black" ></SolidColorBrush>
</Border.BorderBrush>
</Border>
<FontFamily x:Key="TitleFontFamily">
Arial
</FontFamily>
<FontWeight x:Key="TitleFontWeight">
Bold
</FontWeight>
<!-- Other formats go here... -->
</Style.Resources>
</Style>
As seen in the listing, all separate resources within the style have x:Key attributes specified. As this is seemingly required (as VS complains if it is missing), there must obviously be a reason for that.
From elsewhere in the XAML code, the style can be referenced with {StaticResource GroupBoxFormat}. However, if I want to refer from outside to any of the "inner" properties, say, "BorderFormat" - how do I do that? Something like "dot" notation within C# for accessing object members like SomeObject.SomeMember. Staying in the example, It could be illustrated like "GroupBoxFormat.BorderFormat". I just need the "XAML" way of doing that.