title: Trigger textbox's text value change when backgroundColor = Red
body: <p>What am I doing wrong here? </p>
  
  <p>I'm trying to change TextBox's text value when its background is red.</p>
  
  <p>I can fire this trigger with any other property (like when Width = 123, text is changing properly) - so <strong>it must be something with my "Red" value</strong>.</p>
  
  <p>I tried this way:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type TextBox}" x:Key="t"&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Background"&gt;
              &lt;Trigger.Value&gt;
                  &lt;SolidColorBrush Color="Red"/&gt;
              &lt;/Trigger.Value&gt;
          &lt;/Trigger&gt;
  
          &lt;Trigger.Setters&gt;
             &lt;Setter Property="Text" Value="Haha! Red detected!"/&gt;
          &lt;/Trigger.Setters&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>and that way</p>
  
  <pre><code>&lt;Style TargetType="{x:Type TextBox}" x:Key="t"&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="Background" Value="Red"/&gt;
  
          &lt;Trigger.Setters&gt;
             &lt;Setter Property="Text" Value="Haha! Red detected!"/&gt;
          &lt;/Trigger.Setters&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>No reaction.</p>
  
  <hr>
  
  <p>Here's xaml</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication3.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="MainWindow" Height="350" Width="525"&gt;
  &lt;Window.Resources&gt;
      &lt;Style TargetType="{x:Type TextBox}" x:Key="t"&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="Background"&gt;
                  &lt;Trigger.Value&gt;
                      &lt;SolidColorBrush Color="Red"/&gt;
                  &lt;/Trigger.Value&gt;
                  &lt;Trigger.Setters&gt;
                      &lt;Setter Property="Text" Value="It's working!"/&gt;
                  &lt;/Trigger.Setters&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  &lt;/Window.Resources&gt;
  &lt;StackPanel&gt;
      &lt;TextBox x:Name="tb" Style="{StaticResource t}" Text="White background" Background="White"&gt;&lt;/TextBox&gt;
      &lt;Button Height="68" Content="ChangeBackground" Click="Button_Click"&gt;&lt;/Button&gt;
  &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And codebehind</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  
  namespace WpfApplication3
  {
  /// &lt;summary&gt;
  /// Interaction logic for MainWindow.xaml
  /// &lt;/summary&gt;
  public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
      }
  
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          tb.Background = new SolidColorBrush(Colors.Red);
      }
  }
  }
  </code></pre>