title: How to use template binding inside data template in custom control (Silverlight)
body: <p>I am trying to create control which will take <code>ItemsSource</code> and <code>InnerTemplate</code> and will show all the items wrapped in <code>CheckBox</code>es.</p>
  
  <p>The control has 2 dependency properties:</p>
  
  <pre><code>public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(CheckBoxWrapperList), null);
  public static readonly DependencyProperty InnerTemplateProperty = DependencyProperty.Register("InnerTemplate", typeof(DataTemplate), typeof(CheckBoxWrapperList), null);
  </code></pre>
  
  <p>and here is the template:</p>
  
  <pre><code>&lt;ControlTemplate TargetType="local:CheckBoxWrapperList"&gt;
      &lt;Grid&gt;
          &lt;Grid.Resources&gt;
              &lt;DataTemplate x:Key="wrapper"&gt;
                  &lt;CheckBox&gt;
                      &lt;ContentPresenter ContentTemplate="{TemplateBinding InnerTemplate}" Content="{Binding}" /&gt;
                  &lt;/CheckBox&gt;
              &lt;/DataTemplate&gt;
          &lt;/Grid.Resources&gt;
          &lt;ItemsControl ItemTemplate="{StaticResource wrapper}" ItemsSource="{TemplateBinding ItemsSource}" /&gt;
      &lt;/Grid&gt;
  &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>However, this approach does not work.<br>
  Binding in the <code>ControlPresenter.ContentTemplate</code> using <code>TemplateBinding</code> does not work.<br>
  However, when I don't use template binding and reference the template as static resource, then it works as expected.</p>
  
  <ul>
  <li>Why cannot I use the template binding inside the content presenter in datatemplate?  </li>
  <li>What am I missing here? Any special markup required?  </li>
  <li>Is there a way to achieve the expected behavior?</li>
  </ul>
  
  <p>Thanks in advance.</p>