title: WPF C# Programmatically adding Styles from Resource Dictionary?
body: <p>I am new to this website and new to programming and I have encountered a problem.
  I am using Visual Studio 2010, C# WPF Application.</p>
  
  <p>I have this line of code in my program:</p>
  
  <pre><code>    TextBlock.Inlines.Add
                    (new Run("text"){ Foreground = Brushes.Blue, FontWeight = FontWeights.ExtraBold });
  </code></pre>
  
  <p>This Line doesn't have any problems, but I have a Resource Dictionary already made with those setters and I'm not sure how I can use it programmatically for each line. I tried something like this but it didn't do anything:</p>
  
  <pre><code>TextBlock.Inlines.Add
               (new Run("text") { Style = (Style)this.Resources["bluebold"] });
  </code></pre>
  
  <p>What I think the problem might be is that I'm not calling the Resource dictionary which is called "Styles.xaml" in the code and I am unsure on how to do that.</p>