【发布时间】:2012-08-25 05:28:30
【问题描述】:
如何在网格样式中设置Grid 中所有子元素的Foreground 颜色?我知道我以前做过,但我不记得在哪里或如何做。
<Style x:Key="MyGridStyle" TargetType="{x:Type Grid}">
// I want to set the font color here
</Style>
<Grid Style="{StaticResource MyGridStyle}">
...
</Grid>
我知道我可以使用
<Grid.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="Red" />
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Foreground" Value="Red" />
</Style>
</Grid.Resources>
但是我想在Style 中设置这个值,而不是在Grid 中
【问题讨论】: