StringFormat Axis Label
Where would I put my StringFormat={}{0:C} to make the axis label have currency formatting?
<DVC:LinearAxis Orientation="X" Interval="500000" ShowGridLines="True" Minimum="0" >
<DVC:LinearAxis.AxisLabelStyle>
<Style TargetType="DVC:AxisLabel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DVC:AxisLabel">
<TextBlock Text="{TemplateBinding FormattedContent}">
<TextBlock.LayoutTransform>
<RotateTransfor开发者_高级运维m Angle="60"/>
</TextBlock.LayoutTransform>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DVC:LinearAxis.AxisLabelStyle>
</DVC:LinearAxis>
This could help you http://wpf.codeplex.com/Thread/View.aspx?ThreadId=75399
HTH
Not tested, but I think this will do the trick:
<TextBlock Text="{TemplateBinding FormattedContent, StringFormat={}{0:C}}">
(It's the 7th line of your posted code.)
ContentStringFormat dont work anymore on SL4, this way worked for me, suggested by andulvar on sl forum:
if you need only a StringFormat:
<TextBox DataContext="{TemplateBinding Value}"
Text="{Binding StringFormat='\{0:MM/dd HH:mm\} '}"/>
or if you want to use a Converter:
<TextBox DataContext="{TemplateBinding Value}"
Text="{Binding Converter={StaticResource Double2String}}"/>
I hope this way help someone, I spent a lot of time to find the right way to do this.
Even better, you can go ahead and put a customized text instead of just a number or a Date on a X, Y axis. All you need is a Converter in between to translate a value (Number, Date) to a mush more meaningful text.
<chartingToolkit:LinearAxis Orientation="X" ShowGridLines="True">
<chartingToolkit:LinearAxis.AxisLabelStyle>
<Style TargetType="chartingToolkit:AxisLabel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:AxisLabel">
<TextBlock Text="{TemplateBinding FormattedContent, Converter={StaticResource MileTextConverter}}"></TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</chartingToolkit:LinearAxis.AxisLabelStyle>
</chartingToolkit:LinearAxis>
<Label>
<Label.Content>
<ContentPresenter Content="{TemplateBinding FormattedContent}" ContentStringFormat="{}{0:C}" />
</Label.Content>
</Label>
精彩评论