title: WPF Using the Tag Element to Bind a Color
body: <p>I want to create a Slider that has a Gradient from Black to a certain Color as a Background.
  The color is to be set additionally to the Style of the Slider. AFAIK, no extra properties can be added to a given control using just Control Templates (i.e. no attached properties and no derived controls).</p>
  
  <p>I therefore want to use the Tag property and have created this snippet:</p>
  
  <pre><code>&lt;Style x:Key="ColorSlider" TargetType="{x:Type Slider}"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Slider}"&gt;
                  &lt;Grid&gt;
                      &lt;Rectangle Grid.Column="1" Grid.Row="1"&gt;
                              &lt;Rectangle.Fill&gt;
                                  &lt;LinearGradientBrush StartPoint="0,0" EndPoint="0,1" &gt;
                                      &lt;GradientStop Color="{TemplateBinding Tag}" Offset="0.0"/&gt;
                                      &lt;GradientStop Color="Black" Offset="1.0"/&gt;
                                  &lt;/LinearGradientBrush&gt;
                              &lt;/Rectangle.Fill&gt;
                          &lt;/Rectangle&gt;
  
                          ....
                      &lt;/Grid&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>and use it like this:</p>
  
  <pre><code>&lt;Slider Style="{StaticResource ColorSlider}" Width="100" Height="500" Tag="{StaticResource redColor}"/&gt;
  </code></pre>
  
  <p>with <code>redColor</code> beeing a static resource (although I'd prefer typing colors directly using HEX codes or predefined colors).</p>
  
  <p>This however doesn't work, any idea why?</p>