Create Style for a StackPanel and its Contents
resourcedictionary, styles, wpf
Solution
You would have something like this in your resource dictionary:
<Style TargetType="StackPanel" x:Key="GlobalStackPanelStyle">
<Style.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="Green" />
</Style>
</Style.Resources>
</Style>
Problem
I want to create a style for Stackpanels using a key. This style will be in a global ResourceDictionary for use everywhere in the application. But it should not only set the style of the Stackpanel, but also its content. I want to use the stackpanel like this: ``` <StackPanel Style="{StaticResource GlobalStackPanelStyle}"> <Button>test</Button> <-- the button style should also be defined due to the Stackpanel style </StackPanel> ``` How should the Resourcedictionary look like if for example all the containing buttons should be green?