title: Style a XAML button control with C#
body: <p>I have a XAML button control that looks like so:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;Button x:Name="my-button" Grid.Row="3" Content="See More Foo" Click="my-button_Click" Style="{StaticResource BlueButtonStyle}" Width="75" Height="23" HorizontalAlignment="Right" Margin="10,20,90,0" /&gt;
  </code></pre>
  
  <p>I'd like to change the style of the button in a C# method along the lines of:</p>
  
  
  
  <pre><code>public void ChangeButtonColor()
  {
      //Change the style attribute of my-button to RedButtonStyle
  }
  </code></pre>
  
  <p>How would I go about accessing the XAML control in the C# code behind?</p>
  
  <p>This is in a Silverlight 4.0 application.</p>