title: Default TextBlock style overriding button text color
body: <p>My problem occurs with WPF in .NET 3.5 SP1 and can be described as follows:</p>
  
  <p>I have a default <code>Style</code> hitting all <code>TextBlock</code> elements in my UI. That is how it looks:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type TextBlock}"&gt;
     &lt;Setter Property="TextTrimming" Value="CharacterEllipsis"/&gt;
     &lt;Setter Property="Foreground" Value="Red"/&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>That works fine for all <code>TextBlock</code>s. In addition to that I have a <code>Button</code> style including a <code>ControlTemplate</code> that looks like this (shortened):</p>
  
  <pre><code>&lt;Style x:Key="MyButtonStyle" TargetType="{x:Type Button}" BasedOn="{x:Null}"&gt;
     &lt;Setter Property="Foreground" Value="Green"/&gt;
     &lt;Setter Property="Template"&gt;
        &lt;Setter.Value&gt;
           &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
              &lt;Border x:Name="Border" 
                      Background="{TemplateBinding Background}" 
                      BorderThickness="{TemplateBinding BorderThickness}" 
                      Padding="{TemplateBinding Padding}" 
                      Height="24" 
                      BorderBrush="{TemplateBinding BorderBrush}"&gt;
                 &lt;ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                   VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                   TextBlock.Foreground="{TemplateBinding Foreground}"/&gt;
              &lt;/Border&gt;
              &lt;ControlTemplate.Triggers&gt;...&lt;/ControlTemplate.Triggers&gt;
           &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
     &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Notice the line <code>TextBlock.Foreground="{TemplateBinding Foreground}"</code> in the <code>ContentPresenter</code>. This should set the button text to green and in fact it does in the designer view of Visual Studio. But when I compile and run the program the button text is red, the text color is set by the default <code>TextBlock</code> style. I verified this with Snoop.</p>
  
  <p>How can I prevent the default<code>TextBlock</code> style from overriding the <code>TextBlock.Foreground</code> value? The <code>OverridesDefaultStyle</code> property of <code>ContentPresenter</code> doesn't help in this case.</p>
  
  <p>Any idea?</p>