title: WPF: Dynamic Actions in Template
body: <p>I've defined a control Template for a progressbar to make it look like a thermometer ... now i want it to change its color when reaching a certain value (for example .. when the progressbar has the value 70, its color should change to yellow)</p>
  
  <p>Currently the color of PART_Indicator is bound to the background color of the progressbar .. the backgroundcolor is changed in the ValueChanged Eventhandler, and so the color of the indicator changes too... is there a possibility to do this within the template only, so i dont need to use the ValueChanged Eventhandler?</p>
  
  <pre><code>    &lt;ControlTemplate x:Key="myThermometer" TargetType="{x:Type ProgressBar}"&gt;
      &lt;ControlTemplate.Resources&gt;
          &lt;RadialGradientBrush x:Key="brushBowl" GradientOrigin="0.5 0.5"&gt;
              &lt;GradientStop Offset="0" Color="Pink" /&gt;
              &lt;GradientStop Offset="1" Color="Red" /&gt;
          &lt;/RadialGradientBrush&gt;
      &lt;/ControlTemplate.Resources&gt;
      &lt;Canvas&gt;
          &lt;Path Name="PART_Track" Stroke="Black" StrokeThickness="5" Grid.Column="0"&gt;
              &lt;Path.Data&gt;
                  &lt;CombinedGeometry GeometryCombineMode="Union"&gt;
                      &lt;CombinedGeometry.Geometry1&gt;
                          &lt;RectangleGeometry Rect="10,40,130,20" RadiusX="5" RadiusY="5"/&gt;
                      &lt;/CombinedGeometry.Geometry1&gt;
                      &lt;CombinedGeometry.Geometry2&gt;
                          &lt;EllipseGeometry Center="10,50" RadiusX="20" RadiusY="20"/&gt;
                      &lt;/CombinedGeometry.Geometry2&gt;
                  &lt;/CombinedGeometry&gt;
              &lt;/Path.Data&gt;
          &lt;/Path&gt;
  
          &lt;Path Fill="{TemplateBinding Background}"&gt;
              &lt;Path.Data&gt;
                  &lt;EllipseGeometry Center="10,50" RadiusX="17" RadiusY="17"/&gt;
              &lt;/Path.Data&gt;
          &lt;/Path&gt;
  
          &lt;Path Name="PART_Indicator" Fill="{TemplateBinding Background}" Grid.Column="0"&gt;
              &lt;Path.Data&gt;
                  &lt;RectangleGeometry Rect="22,43,115,15" RadiusX="5" RadiusY="5"/&gt;
              &lt;/Path.Data&gt;
          &lt;/Path&gt;
  
          &lt;Canvas Canvas.Top="35" Canvas.Right="375"&gt;
              &lt;Canvas.RenderTransform&gt;
                  &lt;RotateTransform CenterX="120" CenterY="120" Angle="-270" /&gt;
              &lt;/Canvas.RenderTransform&gt;
              &lt;TextBlock FontWeight="Bold" FontSize="16" Foreground="Black" Text="{TemplateBinding Tag}"/&gt;
          &lt;/Canvas&gt;
      &lt;/Canvas&gt;       
  &lt;/ControlTemplate&gt;
  </code></pre>