title: How to set a binding inside a style?
body: <p>I am fairly new to Xaml. <br>
  I am learning UWP(Universal Windows Platform) and I have more buttons and I want to bind their Background property to a property of a ViewModel that will change during some events.</p>
  
  <p>I implemented the INotifyPropertyChanged and everything works ok (the color of the buttons change) when I bind the Background property in the Buttons' declaration in XAML:</p>
  
  <pre><code>&lt;Button Content="0" Grid.Column="0" Grid.Row="5"
                  Background="{Binding ButtonColor, Source={StaticResource AppViewModel}}" Style="{StaticResource BasicButton}"/&gt;
  </code></pre>
  
  <p>StaticResource AppViewModel is a resource in App.xaml:</p>
  
  <pre><code>&lt;Application.Resources&gt;
      &lt;viewModel:AppViewModel x:Key="AppViewModel" /&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p>I don't know how ok is to declare a ViewModel for App.xaml, but it's a solution I found for having global variables (the variables are held inside the viewModel).</p>
  
  <p>Now back to my question:
  As I don't want to bind the Background on every single button, I tried to add it on the style like this:</p>
  
  <pre><code>&lt;Style x:Key="BasicButton" TargetType="Button"&gt;
              &lt;Setter Property="Background" Value="{Binding ButtonColor, Source={StaticResource AppViewModel}}" /&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>But now when the color variable is changing during running the app, the UI doesn't update anymore.
  It seems that binded properties in styles don't respond to changes of variables.</p>
  
  <p>What am I doing wrong?
  Thank you for any answers.</p>