title: How to update SolidColorBrush color with a DynamicResource?
body: <p>I'm trying to change the color of the brush dynamically. I wrote a very simple example but I don't understand why it does not work.</p>
  <p>I have defined a foreground color, and a foreground brush that uses that color as a DynamicResource, in a ResourceDictionary from my app:</p>
  <pre><code>&lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
                      xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&gt;
  
      &lt;Color x:Key=&quot;Foreground&quot;&gt;#FF0000&lt;/Color&gt;
      &lt;SolidColorBrush x:Key=&quot;ForegroundBrush&quot; Color=&quot;{DynamicResource Foreground}&quot; /&gt;
  
  &lt;/ResourceDictionary&gt;
  </code></pre>
  <p>Then, in my Window.xaml I use the brush to set the textblock foreground:</p>
  <pre><code>&lt;Window x:Class=&quot;DictionaryColorTests.MainWindow&quot;
          xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
          xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
          Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot;&gt;
      &lt;Grid&gt;
          &lt;StackPanel&gt;
              &lt;TextBlock Name=&quot;mTextBlock&quot;  Foreground=&quot;{DynamicResource ForegroundBrush}&quot;&gt;This is just a text block&lt;/TextBlock&gt;
              &lt;Button Name=&quot;Button1&quot; Click=&quot;Button1_Click&quot;&gt;Change color&lt;/Button&gt;
          &lt;/StackPanel&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  <p>Finally in my code behind, I'm changing the color:</p>
  <pre><code>private void Button1_Click(object sender, RoutedEventArgs e)
  {
      Application.Current.Resources[&quot;Foreground&quot;] = Colors.Green;
  }
  </code></pre>
  <p>Unfortunately, the brush color is not updated. Someone could please explain why?</p>
  <p>NOTE: I know that <strong>if I change directly the color of the brush it works</strong> fine, but I'm trying to understand why a SolidColorBrush that uses a color as a dynamic resource does not update its color when the color changes.</p>
  <hr />
  <h2>UPDATE: Using a style it works as expected</h2>
  <p>If I use a style for the textblock, just updating the color, it works fine and the brush take the right color. What is the difference about using the brush directly or using the style?</p>
  <pre><code>&lt;Style TargetType=&quot;TextBlock&quot; x:Key=&quot;TextBlockStyle&quot;&gt;
      &lt;Setter Property=&quot;Foreground&quot; Value=&quot;{StaticResource ForegroundBrush}&quot; /&gt;
  &lt;/Style&gt;
  </code></pre>