SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components


I can’t seem to directly set the font color of a VerticalLineAnnotation.
I found this link which shows how to set it directly, but that doesn’t seem to do anything either (is it broken again?)
Here is some of my code:

    <Style x:Key="sliceStyle" TargetType="s:VerticalLineAnnotation">
        <Setter Property="ShowLabel" Value="True"/>
        <Setter Property="Stroke" Value="#ff4"/>
        <Setter Property="IsEditable" Value="True"/>
        <Setter Property="Foreground" Value="#225"/>
        <Setter Property="LabelPlacement" Value="Axis"/>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Stroke" Value="Blue"/>
                                <s:VerticalSliceModifier Name="sliceModifier">
                                        <s:VerticalLineAnnotation Style="{StaticResource sliceStyle}" X1="1" />
                                        <s:VerticalLineAnnotation  X1="3" Stroke="#ff4" IsEditable="True" LabelPlacement="Axis" ShowLabel="True" >
                                            <s:AnnotationLabel LabelPlacement="TopRight" Text="initially3" Foreground="Green"/>

Thanks for any insight!

  • You must to post comments

Hi there,

AnnotationLabel has this style defined in our control templates:

<!--  Apply to AnnotationLabel.LabelStyle -->
<Style x:Key="annotationLabel" TargetType="a:AnnotationLabel">
    <Setter Property="Text" Value="{Binding FormattedLabel, Mode=OneWay}" />
    <Setter Property="Foreground" Value="{Binding Stroke}" />
    <Setter Property="BorderThickness" Value="0" />
<!--  Apply to AnnotationLabel.AxisLabelStyle -->
<Style x:Key="annotationAxisLabel" TargetType="a:AnnotationLabel">
    <Setter Property="Text" Value="{Binding FormattedLabel, Mode=OneWay}" />
    <Setter Property="Foreground" Value="{z:ThemeBinding Path=TickTextBrush}" />
    <Setter Property="Background" Value="{Binding Stroke}" />
    <Setter Property="BorderBrush" Value="{Binding Stroke}" />
    <Setter Property="BorderThickness" Value="{Binding StrokeThickness, Converter={StaticResource DoubleToThicknessConverter}}" />
    <Setter Property="CornerRadius" Value="2" />

If you create your own styles you can apply them to an annotation label like this

<s:AnnotationLabel LabelStyle="{StaticResource annotationLabel}" AxisLabelStyle="{staticresource annotationAxisLabel}"/>

The DataContext for an AnnotationLabel is the parent VerticalLineAnnotation, so by default Foreground of an AnnotationLabel is bound to Stroke (foreground of an axis label is bound to IThemeProvider.TickTextBrush) but this can be changed.

Hope this helps!

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.