title: WPF : Adding Border to an image programmatically
body: <p>I want to add a style to the the image programmatically. Here is my code</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
         &lt;Style x:Name="BranchPages" x:Key="BranchPages"&gt;
              &lt;Setter Property="Control.Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate&gt;
                          &lt;Border BorderThickness="2" BorderBrush="Green"&gt;
                          &lt;/Border&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Style&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>and the code behid is as follows</p>
  
  <pre><code>  Style greenbdr = (Style)FindResource("BranchPages");
    page.img.Style = greenbdr;
  </code></pre>
  
  <p>But Its not working Please help</p>