title: Binding Style template - a way that works?
body: <p>I've been trying (failing) to create a button template, to be shared between libraries. The template is (currently) basically a bordered circle inside a bordered circle. In order to make the inner border's size smaller than the outer, I use a Converter on the binding. I'd like to pass in a property of the TemplatedParent as a ConverterParameter but it just doesn't work, apparently by design. The bit that doesn't work is because I'm trying to bind a ConveterParameter to a TemplatedParent property.</p>
  
  <p>Here's my Style def (in a ResourceDictionary):</p>
  
  <pre><code>&lt;SolidColorBrush x:Key="MyBorderFillColour"&gt;Yellow&lt;/SolidColorBrush&gt;
  &lt;SolidColorBrush x:Key="MyBorderEdgeColour"&gt;#ff652f00&lt;/SolidColorBrush&gt;
  &lt;SolidColorBrush x:Key="MyGeneralFillColour"&gt;#ffffffbd&lt;/SolidColorBrush&gt;
  &lt;s:Int32 x:Key="MyBorderThickness"&gt;10&lt;/s:Int32&gt;
  
  &lt;l:RelativeSizeConverter x:Key="RelativeSizeConverter" /&gt;
  
  &lt;Style x:Key="MyButtonStyle" TargetType="Button"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
                  &lt;Grid&gt;
                      &lt;Ellipse 
                          Fill="{StaticResource MyBorderFillColour}" 
                          StrokeThickness="2" 
                          Stroke="{StaticResource MyBorderEdgeColour}" 
                          Height="{TemplateBinding Height}" 
                          Width="{TemplateBinding Width}" /&gt;
                      &lt;Ellipse StrokeThickness="2" 
                          Stroke="{StaticResource MyBorderEdgeColour}" 
                          Fill="{StaticResource MyGeneralFillColour}"
                          Height="{Binding Path=Height,
                              RelativeSource={RelativeSource TemplatedParent}, 
                              Converter={StaticResource RelativeSizeConverter},
                              ConverterParameter={StaticResource MyBorderThickness}}"
                          Width="{Binding Path=Width,
                              RelativeSource={RelativeSource TemplatedParent}, 
                              Converter={StaticResource RelativeSizeConverter},
                              ConverterParameter={TemplateBinding BorderThickness}}" /&gt;
                      &lt;TextBlock 
                          Text="{TemplateBinding Content}" 
                          HorizontalAlignment="Center" 
                          VerticalAlignment="Center" 
                          Foreground="Black" 
                          FontFamily="Calibri"
                          FontWeight="Bold"
                          FontSize="17" /&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>The second Ellipse's Height works using a StaticResource, but Width doesn't work using the TemplateBinding approach.  I've also tried</p>
  
  <pre><code>ConverterParameter={Binding Path=BorderThickness,RelativeSource={RelativeSource TemplatedParent}}
  </code></pre>
  
  <p>Any idea how to achieve my aim?!?</p>
  
  <p>Thanks for any help,</p>