Pre loader

Templating AnnotationLabel

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
0

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>
Version
5.3.0.11954
  • Andrew Burnett-Thompson
    Sorry Patrick, we cannot help customers who have expired technical support subscriptions. If you would like to renew or update, then contact sales, we will be glad to help. Best regards, Andrew
  • You must to post comments
Showing 0 results
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