title: Set StaticResource style of a control dynamically in the code
body: <p>Let's say, I've got something like this (in MainPage.xaml):</p>
  
  <pre><code>&lt;Page.Resources&gt;
      &lt;Style TargetType="TextBlock" x:Key="TextBlockStyle"&gt;
          &lt;Setter Property="FontFamily" Value="Segoe UI Light" /&gt;
          &lt;Setter Property="Background" Value="Navy" /&gt;
      &lt;/Style&gt;
  &lt;/Page.Resources&gt;
  </code></pre>
  
  <p>Then, I would like to apply that StaticResource style to my dynamic created TextBlock (file MainPage.xaml.cs).</p>
  
  <p>Is there any possibility to do this instead of doing something like this:</p>
  
  <pre><code>myTextBlock.FontFamily = new FontFamily("Segoe UI Light");
  myTextBlock.Background = new SolidColorBrush(Color.FromArgb(255,0,0,128));
  </code></pre>