title: Setting styles for subcontrols of usercontrol
body: <p>Say I have a user control like this:</p>
  
  <pre><code>&lt;UserControl x:Class="StyleTest.UserControl1"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           mc:Ignorable="d" 
           d:DesignHeight="300" d:DesignWidth="300"&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition /&gt;
          &lt;RowDefinition /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Button Grid.Row="0"&gt;Style please&lt;/Button&gt;
      &lt;Button Grid.Row="1"&gt;Style please&lt;/Button&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>And I want to set all buttons in this control to background=green.
  But I don't want to affect other buttons in my program and I don't want to modify the code of the control.</p>
  
  <p>What I found right now is this:</p>
  
  <pre><code>&lt;Window x:Class="StyleTest.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:loc="clr-namespace:StyleTest"
      Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Window.Resources&gt;
      &lt;Style x:Key="UserControlStyles" TargetType="Button"&gt;
          &lt;Setter Property="Background" Value="green" /&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition /&gt;
          &lt;ColumnDefinition /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Button Grid.Column="0"&gt;no Style please&lt;/Button&gt;
      &lt;loc:UserControl1 Grid.Column="1"&gt;
          &lt;loc:UserControl1.Resources&gt;
              &lt;Style TargetType="Button" BasedOn="{StaticResource UserControlStyles}" /&gt;
          &lt;/loc:UserControl1.Resources&gt;
      &lt;/loc:UserControl1&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>But this would imply that I have to add this code to every instance of the control, and some extra code, if I want to style e.g. foreground color of TextBoxes also.</p>
  
  <p>What I am looking for is something similar to this:</p>
  
  <pre><code>        &lt;Style TargetType="Buttons that are childs of UserControl1"&gt;
          &lt;Setter Property="Background" Value="green" /&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>Is there a way of doing this?</p>
  
  <p>I don't think that a control template would be sufficient, because I don't want to redesign the whole control, I just want to set the color of the buttons.</p>