I am trying to conditionally format numbers that appear on the NumericAxis axis for LineSeries (from the Silverlight 4 toolbox). To be more specific, I want the numbers of> = 10000 and <= 0.0001 to appear in scientific notation, but I can't do this work.
I can override the NumericAxisLabel template as follows:
<Style x:Key="NumericAxisLabelStyle" TargetType="chartingToolkit:NumericAxisLabel">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="StringFormat" Value="{}{0:0.0E+00}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chartingToolkit:NumericAxisLabel">
<TextBlock Text="{TemplateBinding FormattedContent}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
But this will apply the scientific notation format for ALL labels on the axis. I want the string formatting expression to include only when the condition that I mentioned above occurs.
I was able to accomplish this in the LineDataPoint tooltip template quite easily using binding with a custom value converter, for example:
<ControlTemplate TargetType="chartingToolkit:LineDataPoint">
<Grid x:Name="Root" Opacity="0">
<ToolTipService.ToolTip>
<StackPanel Margin="2,2,2,2">
<StackPanel Orientation="Horizontal">
<TextBlock Text="X:" />
<ContentControl Content="{Binding objResultValueX, Converter={StaticResource ToCustomStringFormat}}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Y:" />
<ContentControl Content="{Binding dblResultValueY, Converter={StaticResource ToCustomStringFormat}}"/>
</StackPanel>
</StackPanel>
</ToolTipService.ToolTip>
...
</Grid>
</ControlTemplate>
"FormattedContent" NumericAxisLabelStyle, LineDataPoint... , !
?
!