title: How is TemplateBinding working in UserControl Template?
body: <p>I am new one to create UserControl and now I am trying to customize the UserControl Template as below:</p>
  
  <pre><code>&lt;UserControl x:Class="WpfApplication1.PieButton"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               mc:Ignorable="d" 
               d:DesignHeight="300" d:DesignWidth="300" Loaded="OnLoaded"&gt;
      &lt;UserControl.Template&gt;
          &lt;ControlTemplate&gt;
              &lt;Path Name="path" Stroke="Aqua" StrokeThickness="3"&gt;
                  &lt;Path.Fill&gt;
                      &lt;SolidColorBrush Color="{TemplateBinding Fill}" /&gt;
                  &lt;/Path.Fill&gt;
                  &lt;Path.Data&gt;
                  ......
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>At the same time I have create the dependencyproperty in back-end code:</p>
  
  <pre><code>public partial class PieButton : UserControl
  {
      public PieButton()
      {
          InitializeComponent();
      }
  
      private void OnLoaded(object sender, RoutedEventArgs e)
      {
  
      }
  
  
  
      public Color Fill
      {
          get { return (Color)GetValue(FillProperty); }
          set { SetValue(FillProperty, value); }
      }
  
      public static readonly DependencyProperty FillProperty =
          DependencyProperty.Register("Fill", typeof(Color), typeof(PieButton));
      ......
  </code></pre>
  
  <p>I want to use <code>TemplateBinding</code> in XAML to bind <code>Fill</code> property of my PieButton to fill the path object. The Visual Studio Designer warns me that "the Fill property is not accessible or recognized".</p>
  
  <p>Based on my understanding, the <code>TemplateBinding</code> find the property name from the element that apply this ControlTemplate, which should be <code>PieControl</code> here, but why the <code>Fill</code> Property cannot access here?</p>
  
  <p>BTW,</p>
  
  <p>I test the following binding, and it can work for me</p>
  
  <pre><code>Color="Binding Fill,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}"
  </code></pre>
  
  <p>But I still think the TemplateBinding should be able to work under this scenario, so please point out my fault here. Thanks.</p>