title: In a ControlTemplate's trigger, how can I access an element defined in the ControlTemplate's body?
body: <p>I have the following (simplified) ControlTemplate:</p>
  
  <pre><code>&lt;ControlTemplate x:Key="ImageButtonTemplate" TargetType="{x:Type controls:ImageButton}"&gt;
      &lt;Grid x:Name="Grid"&gt;
        &lt;Border [StuffRemoved]/&gt;
        &lt;StackPanel [StuffRemoved]&gt;
          &lt;Image [StuffRemoved] /&gt;
          &lt;ContentPresenter [StuffRemoved] /&gt;
        &lt;/StackPanel&gt;      
  
          &lt;Grid.RenderTransform&gt;
              &lt;ScaleTransform x:Name="ImgBtnScale"/&gt;
          &lt;/Grid.RenderTransform&gt;
      &lt;/Grid&gt;
  
      &lt;ControlTemplate.Triggers&gt;
  
          &lt;!-- problem here! --&gt;
          &lt;Trigger Property="IsPressed" Value="True"&gt;
              &lt;Trigger.Setters&gt;
                  &lt;Setter  TargetName="ImgBtnScale" Property="ScaleX" Value="0.9"/&gt;
                  &lt;Setter TargetName="ImgBtnScale" Property="ScaleY" Value="0.9"/&gt;
              &lt;/Trigger.Setters&gt;
          &lt;/Trigger&gt;      
  
  
          &lt;!-- rest of the stuff works okay--&gt;
  
          &lt;Trigger Property="IsMouseOver" Value="True"&gt;
              &lt;Trigger.EnterActions&gt;
                  &lt;BeginStoryboard&gt;
                      &lt;Storyboard&gt;
                          &lt;DoubleAnimation Storyboard.TargetName="ImgBtnScale" Storyboard.TargetProperty="ScaleX"
                              To="1.2" Duration="0:0:0.1"/&gt;
                          &lt;DoubleAnimation Storyboard.TargetName="ImgBtnScale" Storyboard.TargetProperty="ScaleY"
                              To="1.2" Duration="0:0:0.1"/&gt;
                      &lt;/Storyboard&gt;
                  &lt;/BeginStoryboard&gt;
              &lt;/Trigger.EnterActions&gt;
  
              &lt;Trigger.ExitActions&gt;
                  &lt;BeginStoryboard&gt;
                      &lt;Storyboard&gt;
                          &lt;DoubleAnimation Storyboard.TargetName="ImgBtnScale" Storyboard.TargetProperty="ScaleX"
                              To="1" Duration="0:0:0.1"/&gt;
                          &lt;DoubleAnimation Storyboard.TargetName="ImgBtnScale" Storyboard.TargetProperty="ScaleY"
                              To="1" Duration="0:0:0.1"/&gt;
                      &lt;/Storyboard&gt;
                  &lt;/BeginStoryboard&gt;
              &lt;/Trigger.ExitActions&gt;      
          &lt;/Trigger&gt;
  
      &lt;/ControlTemplate.Triggers&gt;
    &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>It doesn't compile, saying that:</p>
  
  <p><code>Cannot find the target 'ImgBtnScale'. (The  target must appear before any Setters, Triggers or Conditions that use it.)</code></p>
  
  <p>So how do I access <code>ImgBtnScale</code>?</p>