jswigart
Topic Author
Posts: 12
Joined: 14 Mar 2019, 02:35

Unable to use StringFormat in a tab item header?

09 Jan 2020, 04:02

Any reason why I can't get this to work?

It just shows the count, not the formatted string.
<TabItem Header="{Binding Resources.Textures.Count, StringFormat=Textures {0:D}}">

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Unable to use StringFormat in a tab item header?

09 Jan 2020, 10:39

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:
<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 2 guests