Why can't I set the ItemTemplate?

I write:
<datatemplate x:key="ClosableTabItemHeaderTemplate">
<datatemplate.resources>
 <booleantovisibilityconverter x:key="B2V">
</booleantovisibilityconverter></datatemplate.resources>
 <grid background="Transparent" horizontalalignment="Stretch" minwidth="100" tooltip="{Binding}">
<grid.columndefinitions>
<columndefinition>
<columndefinition>
</columndefinition></columndefinition></grid.columndefinitions>

 <contentpresenter content="{Binding}" grid.column="0" horizontalalignment="Center">
 </contentpresenter></grid></datatemplate>
July 9th 19 at 13:18
1 answer
July 9th 19 at 13:20
I think the problem is that you do not understand very well the difference between TabControl.ItemTemplate and TabItem.HeaderTemplate.
Judging by the template you are trying to add a button to close the tab in the header of the header.
If so, then for this purpose use the following code:
<grid>
<grid.resources>
 <datatemplate x:key="ClosableTabItemHeaderTemplate">
<datatemplate.resources>
 <booleantovisibilityconverter x:key="B2V">
</booleantovisibilityconverter></datatemplate.resources>
 <grid background="Transparent" horizontalalignment="Stretch" minwidth="100" tooltip="{Binding}">
<grid.columndefinitions>
<columndefinition>
<columndefinition>
</columndefinition></columndefinition></grid.columndefinitions>

 <contentpresenter content="{Binding}" grid.column="0" horizontalalignment="Center">
 </contentpresenter></grid></datatemplate></grid.resources></grid>

Find more questions by tags C#WPFXAML