title: WPF Reusing a Template in other ControlTemplates
body: <p>I am currently trying to figure out how to reuse a template in other controltemplates (as the title says). What I am trying to do is make a bunch of buttons that are all slightly different but have several similar features. They all share several of the same graphical elements and have the same triggers that deal with those graphical elements. What I am hoping to do is be able to take that code out and put it into another template and just have all of the buttons reference to that template. That way it is easier to manager and just makes more sense overall. I'm sure there is a way but I'm still kind of new to WPF. Thanks for any help!</p>
  
  <p>EDIT:
  Here is some code showing what I want to do.</p>
  
  <pre><code>&lt;ControlTemplate x:Key="LeftJustifyButtonTemplate" TargetType="{x:Type RadioButton}"&gt;
      &lt;Grid Width="24" Height="24"&gt;
          &lt;Rectangle HorizontalAlignment="Stretch" Fill="#00000000" Stroke="{x:Null}"/&gt;
          &lt;Rectangle x:Name="backRectangle" HorizontalAlignment="Stretch" Margin="0,0,0,0" Stroke="#FFB9B9B9" StrokeThickness="0.5" RadiusX="4" RadiusY="4" Visibility="Hidden"&gt;
              &lt;Rectangle.Fill&gt;
                  &lt;LinearGradientBrush EndPoint="0.146,0.146" StartPoint="2.057,2.057"&gt;
                      &lt;GradientStop Color="#FF000000" Offset="0"/&gt;
                      &lt;GradientStop Color="#FFFFFFFF" Offset="1"/&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Rectangle.Fill&gt;
          &lt;/Rectangle&gt;
          &lt;Rectangle x:Name="foreRectangle" Margin="1,1,1,1" VerticalAlignment="Stretch" Fill="#FFE0E0E0" Stroke="{x:Null}" StrokeThickness="0.5" RadiusX="4" RadiusY="4" Visibility="Hidden"/&gt;
          &lt;Path Margin="2.875,7,2.875,0" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Data="M2.875,7.5 L21.145964,7.5" VerticalAlignment="Top" Height="1" StrokeThickness="0.5"/&gt;
          &lt;Path Margin="2.875,9.375,8,0" VerticalAlignment="Top" Height="1" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Data="M3.625,4 L17.514069,4" StrokeThickness="0.5"/&gt;
          &lt;Path Margin="2.875,11.5,2.875,11.5" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Data="M2.875,7.5 L21.145964,7.5" StrokeThickness="0.5"/&gt;
          &lt;Path Margin="2.875,0,8,9.375" VerticalAlignment="Bottom" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Data="M3.625,4 L17.514069,4" Height="1" StrokeThickness="0.5"/&gt;
          &lt;Path Margin="2.875,0,2.875,7" Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" Data="M2.875,7.5 L21.145964,7.5" VerticalAlignment="Bottom" Height="1" StrokeThickness="0.5"/&gt;
      &lt;/Grid&gt;
      &lt;ControlTemplate.Triggers&gt;
          &lt;Trigger Property="IsMouseOver" Value="True"&gt;
              &lt;Setter TargetName="backRectangle" Property="Visibility" Value="Visible"/&gt;
              &lt;Setter TargetName="foreRectangle" Property="Visibility" Value="Visible"/&gt;
          &lt;/Trigger&gt;
          &lt;Trigger Property="IsChecked" Value="True"&gt;
              &lt;Setter TargetName="backRectangle" Property="Visibility" Value="Visible"/&gt;
              &lt;Setter TargetName="foreRectangle" Property="Visibility" Value="Visible"/&gt;
              &lt;Setter TargetName="foreRectangle" Property="Fill" Value="#FFFFFFFF"/&gt;
          &lt;/Trigger&gt;
      &lt;/ControlTemplate.Triggers&gt;
  &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>Pretty much all of that, except for the 5 Paths in the middle, is used in several buttons. This is because it is used for the mouse over and checked triggers. What I want to do is be able to have all of that code be in one place and then have several buttons be able to reference that code.</p>