title: How do I bind a datatrigger in xaml to a code-defined dependency property?
body: <p>My code behind for a window defines a dependency property, "Active"...</p>
  
  <pre><code>public partial class MainWindow : Window
  {
    public MainWindow() { InitializeComponent(); }
  
    public bool Active
    {
       get { return (bool) GetValue(ActiveProperty); }
       set { SetValue(ActiveProperty, value); }
    }
    public static readonly DependencyProperty ActiveProperty =
        DependencyProperty.Register("Active", typeof(bool), typeof(MainWindow), new UIPropertyMetadata(false));
  }
  </code></pre>
  
  <p>And then I bind to that property using two checkboxes in xaml. I also want to change the fill of a rectangle based on that property. How can I make this work?</p>
  
  <pre><code>&lt;Window x:Class="WpfTest.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"
          DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt;
    &lt;StackPanel&gt;
      &lt;CheckBox IsChecked="{Binding Active}" /&gt;
      &lt;CheckBox IsChecked="{Binding Active}" /&gt;
      &lt;Rectangle Fill="Gray"
                 Width="50"
                 Height="50"&gt;
        &lt;Rectangle.Style&gt;
          &lt;Style TargetType="Rectangle"&gt;
            &lt;Style.Triggers&gt;
              &lt;DataTrigger Binding="{Binding Active}"
                           Value="True"&gt;
                &lt;Setter Property="Fill"
                        Value="Green" /&gt;
              &lt;/DataTrigger&gt;
            &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
        &lt;/Rectangle.Style&gt;
      &lt;/Rectangle&gt;
    &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>Checking one box auto-checks the other, but does not change the rectangle color :(</p>