<ContentControl  Width="250" FontStyle="Italic"  FontSize="16"  Foreground="Red" Height="50">
            <ContentControl Name="cc1"  >
                <TextBlock Text="do not inherit Foreground"></TextBlock>
            </ContentControl>
        </ContentControl>
 
 
 

<!-- The following XAML shows the default style for the ContentControl control -->

<Style TargetType="ContentControl">
      <Setter Property="Foreground" Value="#FF000000"/>
      <Setter Property="HorizontalContentAlignment" Value="Left"/>
      <Setter Property="VerticalContentAlignment" Value="Top"/>
      <Setter Property="Template">
          <Setter.Value>
              <ControlTemplate TargetType="ContentControl">
                  <ContentPresenter
                      Content="{TemplateBinding Content}"
                      ContentTemplate="{TemplateBinding ContentTemplate}"
                      Cursor="{TemplateBinding Cursor}"
                      Margin="{TemplateBinding Padding}"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
              </ControlTemplate>
          </Setter.Value>
      </Setter>
  </Style>

<!-- ContentControl的默认样式设置了Foreground的值-->
posted on 2012-07-20 17:06  微星  阅读(223)  评论(0编辑  收藏  举报