Unable to use StringFormat in a tab item header?
Any reason why I can't get this to work?
It just shows the count, not the formatted string.
It just shows the count, not the formatted string.
Code: Select all
<TabItem Header="{Binding Resources.Textures.Count, StringFormat=Textures {0:D}}">
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Unable to use StringFormat in a tab item header?
StringFormat only applies when target property of the binding is of type String, and in this case TabItem.Header is of type object.
But you can use a TextBlock as Header or as part of the HeaderTemplate, and specify the string format there:
But you can use a TextBlock as Header or as part of the HeaderTemplate, and specify the string format there:
Code: Select all
<TabItem>
<TabItem.Header>
<TextBlock Text="{Binding Resources.Textures.Count, StringFormat=Textures {0:D}}"/>
</TabItem.Header>
</TabItem>
Who is online
Users browsing this forum: No registered users and 17 guests