title: Change Rectangle Fill Based on ColumnWidth of a grid
body: <p>Essentially i want to do as the title says, if the columnwidth is .50 then the rectangle should be red, if it's .75 then it should be amber, and if it's 1 then it should be green.</p>
  
  <p>I thought I could achieve this with DataTriggers but for some reason I am getting "Object Reference Not Set To An Instance Of An Object" error, here is my code, am I missing something here? </p>
  
  <p>FYI the width property will be changed in the backend through a timer_tick event.</p>
  
  <pre><code>&lt;Grid x:Name="Grid1" Width="300" Height="30"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition x:Name="MyColumn1" Width=".50*"&gt;&lt;/ColumnDefinition&gt;
          &lt;ColumnDefinition x:Name="MyColumn2" Width=".50*"&gt;&lt;/ColumnDefinition&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid.Triggers&gt;
          &lt;DataTrigger Binding="{Binding ElementName=MyColumn1,Path=Width}" Value=".50*"&gt;
              &lt;Setter TargetName="rect" Property="Fill" Value="Red"&gt;&lt;/Setter&gt;
          &lt;/DataTrigger&gt;
          &lt;DataTrigger Binding="{Binding ElementName=MyColumn1,Path=Width}" Value=".75*"&gt;
              &lt;Setter TargetName="rect" Property="Fill" Value="Yellow"&gt;&lt;/Setter&gt;
          &lt;/DataTrigger&gt;
          &lt;DataTrigger Binding="{Binding ElementName=MyColumn1,Path=Width}" Value="1"&gt;
              &lt;Setter TargetName="rect" Property="Fill" Value="Green"&gt;&lt;/Setter&gt;
          &lt;/DataTrigger&gt;
      &lt;/Grid.Triggers&gt;
      &lt;Rectangle x:Name="rect" Grid.Column="0" HorizontalAlignment="Stretch"&gt;&lt;/Rectangle&gt;
      &lt;Rectangle Grid.Column="1" Fill="Blue"&gt;&lt;/Rectangle&gt;
  
  &lt;/Grid&gt;
  </code></pre>