我想使用密钥为Stackpanels创建一个样式.此样式将位于全局ResourceDictionary中,以便在应用程序的任何位置使用.但它不仅应该设置Stackpanel的样式,还应该设置其内容.
我想像这样使用stackpanel:
<-- the button style should also be defined due to the Stackpanel style
如果所有包含按钮都应该是绿色的,那么Resourcedictionary应该如何?
您可以在资源字典中使用以下内容:
<Style TargetType="StackPanel" x:Key="GlobalStackPanelStyle"> <Style.Resources> <Style TargetType="Button"> <Setter Property="Background" Value="Green" /> </Style> </Style.Resources> </Style>