I want to put a counter and a description on a TabItem Header:
<TabItem Header="{Binding ElementName=lista_etapas, Path=Items.Count,StringFormat=Etapas: {0}}">
But the StringFormat doesn't work. It only shows the Item Count property of the Datagrid 'lista_etapas'.
Expected: 'Etapas: 32'
Result:
Obs.: I Want to avoid using the <TabItem.Header>, because this creates some problems with my customs templates.
CodePudding user response:
This code is working :
<ListBox Name="lista_etapas">
<ListBoxItem>A</ListBoxItem>
<ListBoxItem>B</ListBoxItem>
</ListBox>
<TabControl>
<TabItem Header="{Binding ElementName=lista_etapas,Path=Items.Count}"
HeaderStringFormat="Etapas: {0}">
</TabItem>
</TabControl>
CodePudding user response:
<TabItem Header="{Binding ElementName=lista_etapas, Path=Items.Count,StringFormat={}Etapas: {0}}">
You need open, close brackets for StringFormat.