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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on where you can earn rep for your questions!



I’m trying to template the LineAnnotation. I have a subclass inheriting from LineAnnotation which has some additional dependency properties. I’m trying to put a border around the LineAnnotation but because it’s in a canvas the border’s size is not correct. How would I go about making the border have the correct width? You can see what I’m getting with the curent template in the image.

Also, is there a way to template IsSelected visuals?

            <ControlTemplate x:Key="LineAnnotationTemplate" TargetType="local:BorderedLineAnnotation">
            <Grid x:Name="PART_LineAnnotationRoot" Margin="{TemplateBinding Margin}">
                <Border BorderBrush="{TemplateBinding IsHighlighted, Converter={StaticResource BooleanToHighlightColorConverter}}" BorderThickness="1">
                    <Line x:Name="PART_Line" Stroke="{TemplateBinding Stroke}" StrokeDashArray="{TemplateBinding StrokeDashArray}" StrokeThickness="{TemplateBinding StrokeThickness}"/>
                <Line x:Name="PART_GhostLine"/>

One last thing, what is “PART_GhostLine”, and what does it do?


  • You must to post comments
Best Answer

Hi there,

The template for the LineAnnotation type is

<Style BasedOn="{StaticResource AnnotationBaseStyle}" TargetType="a:LineAnnotation">
   <Setter Property="Stroke" Value="{me:ThemeBinding RubberBandStrokeBrush}" />
   <Setter Property="StrokeThickness" Value="2.0" />
   <Setter Property="Template">
         <ControlTemplate TargetType="a:LineAnnotation">
            <Grid x:Name="PART_LineAnnotationRoot">
               <Line x:Name="PART_GhostLine"
                    StrokeThickness="{s:Static Member=visuals:ManipulationMargins.AnnotationLineWidth}" /> <!-- defaults to 5 -->
               <Line x:Name="PART_Line"
                    Stroke="{TemplateBinding Stroke}"
                    StrokeDashArray="{TemplateBinding StrokeDashArray}"
                    StrokeThickness="{TemplateBinding StrokeThickness}" />

Where AnnotationBaseStyle is defined as

<!--  Annotations  -->
<Style x:Key="AnnotationBaseStyle" TargetType="a:AnnotationBase">
      <Setter Property="IsTabStop" Value="False" />
      <Setter Property="Foreground" Value="{me:ThemeBinding TickTextBrush}" />
      <Setter Property="FontSize" Value="12" />

The PART_GhostLine provides a thicker, transparent line behind the main line which enables mouse-over to work more responsively. e.g. if the mouse is within 5 pixels of the edges of the line, it will still be detectable.

Does this help you implement your own control template for lines?

Best regards,

  • kewur
    Yes, thank you Andrew. I was able to get the behavior I wanted.
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.