title: WPF Button Background Change on Click and Reset to original when another button in same StackPanel Clicked.
body: <p>I have a StackPanel with a few buttons. I want to change the color of a button when clicked and reset it to the original when another button in StackPanel is clicked. Is it possible with a single style applied on StackPanel or I have to create Style for each button? If yes then how.</p>
  
  <p>Here is the code of Style applied to StackPanel but this changes the color of the button but does not reset it on clicking another button.</p>
  
  <pre><code>&lt;Style TargetType="StackPanel" x:Key="GlobalStackPanelStyle" BasedOn="{StaticResource FlatStackPanel}"&gt;
        &lt;Style.Resources&gt;
              &lt;Style TargetType="Button"&gt;
                  &lt;Setter Property="Button.Background" Value="Blue"/&gt;
                  &lt;Style.Triggers&gt; 
                      &lt;Trigger Property="IsPressed" Value="True"&gt;
                          &lt;Trigger.EnterActions&gt;
                              &lt;BeginStoryboard&gt;
                                  &lt;Storyboard&gt;
                                      &lt;ColorAnimation Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)" To="Green"/&gt;
                                  &lt;/Storyboard&gt;
                              &lt;/BeginStoryboard&gt;
                          &lt;/Trigger.EnterActions&gt;                           
                      &lt;/Trigger&gt;                        
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/Style.Resources&gt;
      &lt;/Style&gt;
  </code></pre>