title: Find a WPF element inside DataTemplate in the code-behind
body: <p>I have a data-template </p>
  
  <pre><code>&lt;Window.Resources&gt;
           &lt;DataTemplate x:Key="BarChartItemsTemplate"&gt;
           &lt;Border Width="385" Height="50"&gt;
              &lt;Grid&gt;
                 &lt;Rectangle Name="rectangleBarChart" Fill="MediumOrchid" StrokeThickness="2" Height="40" Width="{Binding}" HorizontalAlignment="Right" VerticalAlignment="Bottom"&gt;
                    &lt;Rectangle.LayoutTransform&gt;
                       &lt;ScaleTransform ScaleX="4"/&gt;
                    &lt;/Rectangle.LayoutTransform&gt;
                 &lt;/Rectangle&gt;
                 &lt;TextBlock Margin="14" FontWeight="Bold" HorizontalAlignment="Right" VerticalAlignment="Center" Text="{Binding}"&gt;
                    &lt;TextBlock.LayoutTransform&gt;
                       &lt;TransformGroup&gt;
                          &lt;RotateTransform Angle="90"/&gt;
                          &lt;ScaleTransform ScaleX="-1" ScaleY="1"/&gt;
                       &lt;/TransformGroup&gt;
                    &lt;/TextBlock.LayoutTransform&gt;
                 &lt;/TextBlock&gt;
              &lt;/Grid&gt;
           &lt;/Border&gt;
        &lt;/DataTemplate&gt;
    &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>I have a button on the form. I need to change the scale(scaleTransform) the rectangle from the dataTemplate. How am I supposed to access the 'rectangleBarChart' element in the Button_Click event of the above mentioned button ?</p>