I have a custom control as follows:
<CustomControl>
<CustomControl.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</CustomControl.ContentTemplate>
</CustomControl>
In the control template of the CustomControl, I try to bind to the CustomControl.ContentTemplate from within a DataTemplate, but it does not work:
<ListBox
ItemsSource="{Binding SearchResultsList}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<ContentControl
Content="{Binding}"
ContentTemplate="{TemplateBinding ContentTemplate}">
</ContentControl>
<ItemsControl
ItemsSource="{Binding HierarchyPath}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="->"/>
<TextBlock Text="{Binding Name}"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Note: ContentTemplate="{TemplateBinding ContentTemplate}"
I know that you cannot use TemplateBinding inside a Datatemplate, even though the DataTemplate is inside a control template. But does anyone know how to achieve what I want to achieve without using TemplateBinding?