Pre loader

Tag: annotation templating

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

0 votes
0 answers
4k views

We are using HorizontalLineAnnotation and VerticalLineAnnotations on a chart. We have subclassed these classes so that we could use our own AnnotationLabels that display text instead of the value of the line position.

something like this:

`
<s:HorizontalLineAnnotation.Resources>

</s:HorizontalLineAnnotation.Resources>

<s:HorizontalLineAnnotation.Stroke>
    <SolidColorBrush Color="{Binding Color}"/>
</s:HorizontalLineAnnotation.Stroke>

<s:HorizontalLineAnnotation.ToolTip>
    <ToolTip Content="{Binding Label}"  
             Visibility="{Binding Label, Converter={StaticResource EmptyStringToVisibilityCollapsedConverter}}"/>
</s:HorizontalLineAnnotation.ToolTip>

<s:AnnotationLabel x:Name="_annotationLabel" LabelPlacement="Axis" BorderThickness="0" Text="{Binding DataContext.Label}" 
Background="Transparent">
    <s:AnnotationLabel.Foreground>
        <SolidColorBrush Color="{Binding DataContext.Color}"/>
    </s:AnnotationLabel.Foreground>
</s:AnnotationLabel>

`

Now we want to use our own custom control similar to a TextBlock as the axis label. Is it possible to template the AnnotationLabel or maybe another way to accomplish this? The custom control we have is used to highlight part of the text in the textblock (using Runs) for search highlighting so even if we have to do it a different way, that would acceptable.

What I would like to do:
.
.
.

<s:AnnotationLabel x:Name="_annotationLabel" LabelPlacement="Axis" BorderThickness="0" Text="{Binding DataContext.Label}" Background="Transparent">
    <s:AnnotationLabel.Foreground>
        <SolidColorBrush Color="{Binding DataContext.Color}"/>
    </s:AnnotationLabel.Foreground>
    <s:AnnotationLabel.Style>
        <Style TargetType="s:AnnotationLabel">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="s:AnnotationLabel">
                        <controls:HighlightingTextBlock Text="{TemplateBinding Text}" HighlightedText="{Binding 
                                                                                                                    DataContext.HighlightedLabelText}"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </s:AnnotationLabel.Style>
</s:AnnotationLabel>
Showing 1 result

Try SciChart Today

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

Start TrialCase Studies