title: How do I use a code behind property in a trigger to change a control property?
body: <p>I am trying to do a fairly simple thing in my WPF application, or at least I think it's simple.</p>
  
  <p>I have a Window that contains an int property in the code behind. Let's call this one IntProperty. The Window implements the INotifyPropertyChanged interface and IntProperty fires the notification on change. It looks like this:</p>
  
  <pre><code>        public int IntProperty
      {
          get
          {
              return intProperty;
          }
  
          private set
          {
              if (value != intProperty)
              {
                  intProperty = value;
                  NotifyPropertyChanged("IntProperty");
              }
          }
      }
  </code></pre>
  
  <p>In the xaml file I have defined a Rectangle with a specifid color set in the Fill property.</p>
  
  <pre><code>                    &lt;Rectangle x:Name="MyRectangle" Fill="Red" Width="100" Height="5" Margin="3,0,0,0" VerticalAlignment="Center" /&gt;
  </code></pre>
  
  <p>What I want to do now is to set the Fill property depending on the value of IntProperty.
  I'm looking for a few simple xaml lines that trigger this change.</p>
  
  <p>It should look like this (AppWindow is the name of the Window):</p>
  
  <pre><code>&lt;Rectangle x:Name="MyRectangle" Fill="Red" Width="100" Height="5" Margin="3,0,0,0" VerticalAlignment="Center"&gt;
  &lt;Rectangle.Triggers&gt;
      &lt;Trigger SourceName="AppWindow" Property="IntProperty" Value="1"&gt;
          &lt;Setter TargetName="MyRectangle" Property="Fill" Value="Green" /&gt;
      &lt;/Trigger&gt;
  &lt;/Rectangle.Triggers&gt;
  </code></pre>
  
  <p></p>
  
  <p>Is there any easy way to do this? So far I couldn't find any simple solution to this. I would appreciate it, if someone could point me in the right direction.</p>
  
  <p>Thanks!</p>