title: WPF create style without overriding default style
body: <p>In my wpf application I want to style all my TextBoxes. As a result my App.xaml looks like:</p>
  
  <pre><code>&lt;Application x:Class="IM.WindowsApp.App"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               StartupUri="MainWindow.xaml"&gt;
      &lt;Application.Resources&gt;
  
          &lt;Style TargetType="{x:Type TextBox}"&gt;
              &lt;Setter Property="Foreground" Value="Yellow"/&gt;
          &lt;/Style&gt;
  
      &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>In MainWindow.xaml I have:</p>
  
  <pre><code> &lt;TextBox Text="Some Text" /&gt;
  </code></pre>
  
  <p>When I run that its great the text shows yellow just like I expected.</p>
  
  <p><strong>Now here is my problem</strong></p>
  
  <p>Now I want to add some <strong>additional</strong> style to that textbox. As a result I modify my code to look like</p>
  
  <pre><code>&lt;TextBox Text="Some Text"&gt;
      &lt;TextBox.Style&gt;
          &lt;Style TargetType="{x:Type TextBox}"&gt;
              &lt;Setter Property="Opacity" Value=".8" /&gt;
          &lt;/Style&gt;
      &lt;/TextBox.Style&gt;
  &lt;/TextBox&gt;   
  </code></pre>
  
  <p>When I run that my textbox foreground is not yellow any more :( . I do not want to replace the style. </p>
  
  <p><strong>A solution will be to give the original style a resource key. Then I could place <code>BasedOn={StaticRecource MyResourceKey}</code></strong>. That is not a solution since I will have to add <code>Style="{StaticResource MyResourceKey}"</code> to all textboxes on my applicaiton. I will like to avoid doing that.</p>