Issue
Let's use a simple example to illustrate the problem: there is a DateTime resource that displays the DateTime with TextBox and Label respectively.
<Grid>
<Grid.Resources>
<sys:DateTime x:Key="DateTime001">03/29/2012 15:05:30</sys:DateTime>
</Grid.Resources>
<TextBox Text="{Binding Source={StaticResource DateTime001},StringFormat=dddd , Mode=OneWay}"
Height="23" HorizontalAlignment="Left" Margin="28,68,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />
<Label Content="{Binding Source={StaticResource DateTime001}, StringFormat=dddd, Mode=OneWay}"
Height="28" HorizontalAlignment="Left" Margin="28,26,0,0" Name="label1" VerticalAlignment="Top" Width="120" />
</Grid>
Running result
The TextBox shows the complete English week as expected, but the Label format has not changed. We use the exactly same Binding and format strings. What is the difference? If you are careful enough, you can find that the Binding of TextBox is performed on the Text attribute, while the Binding of Label is performed on the Content attribute.
Detailed analysis
Essentially, Control. Content is of the Object type, and Binding. StringFormat is valid only when the Property type of Binding is string.
Through the Binding process of the Label below (from Stackoverflow), we can see the underlying details:
1.Bind the DateTime type value to the Label. Content.
2.The Template of the Label contains ContentPresenter, which is used to display the content.
3.The Label ContentPresenter searches for ContentTemplate and DataTemplate to display the content. If none of the content is found, the Label uses the default Template.
4.The default Template used by ContentPresenter uses the Label. ContentStringFormat attribute to format the object to the string.
5.Note that the above is a simplified process. In essence, ContentPresenter will use its own Template and StringFormat to display the result, the ContentTemplate and ContentStringFormat of the Label are automatically bound to the ContentPresenter's ContentTemplate and StringFormat. In essence, ContentPresenter will first display the ContentTemplate and ContentStringFormat of Label. Therefore, here we can say that CotentPresenter uses the Label Properties for display.
Therefore, for non-String Content, add the attribute definition ContentStringFormat = dddd to display the expected results.