0

您能否在容器(网格、画布等)中声明一个样式,该样式将级联到包含的其他类型的元素?

例如:

<Grid>
    <Declare some style with target type of Label/>
    <label Name="ElementIwantStyleAppliedTo1" Content="Foo"/>
    <StackPanel>
         <label Name="ElementIwantStyleAppliedTo2" Content="Foo"/>
    </StackPanel>
</Grid>
4

1 回答 1

1

这是基础!

使用容器控件的资源属性。

<Grid.Resources>
     <Style TargetType="{x:Type Label}">
          <Setter Property="Foreground" Value="Red" />
     </Style>
</Grid.Resources>
于 2012-04-26T14:26:27.137 回答