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

1
0

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"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Stroke" Value="Blue"/>
            </Trigger>
        </Style.Triggers>
    </Style>
                            <s:SciChartSurface.ChartModifier>
                            <s:ModifierGroup>
                                <s:VerticalSliceModifier Name="sliceModifier">
                                    <s:VerticalSliceModifier.VerticalLines>
                                        <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"/>
                                        </s:VerticalLineAnnotation>
                                    </s:VerticalSliceModifier.VerticalLines>
                                </s:VerticalSliceModifier>
                            </s:ModifierGroup>
                        </s:SciChartSurface.ChartModifier>

Thanks for any insight!

  • You must to post comments
0
0

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" />
</Style>
<!--  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" />
</Style>

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,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.