Pre loader

Is there a way to change the font color of a VerticalLineAnnotation?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies