2012-04-26 9 views
0

他のタイプの要素を含むようにカスケードするコンテナ(グリッド、キャンバスなど)にスタイルを宣言できますか?例についてはwpf style cascade

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

答えて

1

これが基本です!

使用コンテナコントロールのリソースプロパティ。

<Grid.Resources> 
    <Style TargetType="{x:Type Label}"> 
      <Setter Property="Foreground" Value="Red" /> 
    </Style> 
</Grid.Resources>