title: Changing background of DataGridTextColumn if value is between a and b
body: <p>So I'm trying to change the background of a cell in Datagrid depending on its value. So if i would want to change it depending on a static value i would use a StyleTrigger but that's not the case.</p>
  
  <p>For example: I want a green background if the value of the cell is between 80 and 100, an orange background if the value is between 40 and 79 and a red background if it's below 40... How would i accomplish that?</p>
  
  <p>Currently I'm using a StyleTrigger just for testing so don't mind that...</p>
  
  <p>Here's my XAML code:</p>
  
  <pre><code>&lt;DataGrid Background="LightGray" ItemsSource="{Binding Source={StaticResource Properties}, Path=TableData}"
                    AutoGenerateColumns="False" IsReadOnly="True"&gt;
              &lt;DataGrid.Columns &gt;
                  &lt;DataGridTextColumn Width="100" Header="ID" Binding="{Binding ID}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Width="100" Header="Batterie" Binding="{Binding Battery}" &gt;
                      &lt;DataGridTextColumn.ElementStyle&gt;
                          &lt;Style TargetType="{x:Type TextBlock}"&gt;
                              &lt;Style.Triggers&gt;
                                  &lt;Trigger Property="Text" Value="83"&gt;
                                      &lt;Setter Property="Background" Value="LightGreen"/&gt;
                                  &lt;/Trigger&gt;
                              &lt;/Style.Triggers&gt;
                          &lt;/Style&gt;
                      &lt;/DataGridTextColumn.ElementStyle&gt;
                  &lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Width="100" Header="Current Use" Binding="{Binding CurrentUse}"&gt;&lt;/DataGridTextColumn&gt;
                  &lt;DataGridTextColumn Width="100" Header="Occupancy" Binding="{Binding Occupancy}"&gt;&lt;/DataGridTextColumn&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Any help is appreciated!!</p>