title: How can I get a trigger to change the color of a TextBlock based on a DataContext Property?
body: <p>Why does the following code get the runtime error:</p>
  
  <blockquote>
    <p>Members of the Triggers collection must be of type EventTrigger</p>
  </blockquote>
  
  <p>But the EventTrigger element doesn't have a Binding property.</p>
  
  <p>So how do I change the color of the TextBlock based on the DataContext Property?</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="TestTrigger123345.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window1" Height="300" Width="300"&gt;
      &lt;StackPanel HorizontalAlignment="Left"&gt;
          &lt;TextBlock Text="{Binding Status}"&gt;
              &lt;TextBlock.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding Status}" Value="off"&gt;
                      &lt;Setter Property="TextBlock.Background" Value="Red"/&gt;
                  &lt;/DataTrigger&gt;
              &lt;/TextBlock.Triggers&gt;
          &lt;/TextBlock&gt;
      &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>namespace TestTriggers
  {
      public partial class Window1 : Window
      {
          public Window1()
          {
              InitializeComponent();
              DataContext = this;
              Status = "off";
          }
  
          public string Status { get; set; }    
      }
  }
  </code></pre>