Does StringFormat feature of WPF Xaml work on Label.Content? Does StringFormat feature of WPF Xaml work on Label.Content? wpf wpf

Does StringFormat feature of WPF Xaml work on Label.Content?


StringFormat works on properties of type string (when the object you are binding to is being converted to a string the string format is applied). The Content property is of type Object.

You can place a TextBlock inside your label to achieve the desired effect:

<Label Grid.Column="2" Height="23" HorizontalAlignment="Left" Margin="100,10,0,0" Name="tb" VerticalAlignment="Bottom" Width="120">   <TextBlock Text="{Binding Path=Amount, StringFormat={}{0:C}}"/></Label>


Try ContentStringFormat

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/866f7934-8b10-4872-b306-122674fad5fa/

<Label Content=ā€{Binding Amount}ā€ ContentStringFormat=ā€Cā€ />