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



I’m trying to style a text annotation to show 3 rows which are databound to the viewmodel but I can’t seem to get the text annotation to apply the style. Here is the xml I’m using

<Style x:Key="InfoStyle" TargetType="SciChart:TextAnnotation">
            <Setter Property="Background" Value="Black"/>
            <Setter Property="Foreground" Value="Orange"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="ContentTemplate">
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            <TextBlock Grid.Column="0" Text="Net Pos:" Style="{StaticResource TextBlockStyle}"></TextBlock>
                            <TextBlock Grid.Column="1" Text="Avg Buy:" Style="{StaticResource TextBlockStyle}"></TextBlock>
                            <TextBlock Grid.Column="2" Text="Avg Sell:" Style="{StaticResource TextBlockStyle}"></TextBlock>

and C# code

 var labelAnnotation = new TextAnnotation();
            labelAnnotation.X1 = 0.01;
            labelAnnotation.Y1 = 0.01;
labelAnnotation.CoordinateMode = AnnotationCoordinateMode.Relative;
 labelAnnotation.XAxisId = "XAxisBottom";
            labelAnnotation.YAxisId = "YAxisRight";

            labelAnnotation.Style = (Style)this.domForm.domCtrl.domChart.Resources["InfoStyle"];

If I set labelAnnotation.Text = “…”, I am able to see it. Can you tell me why I don’t see anything if I apply the data template ?

  • You must to post comments


You could use CustomAnnotation for this purpose. It provides all needed annotation’s features(ability to place below the surface, relative coordinates) and allows to place any content inside. Please, refer to our Create annotations dynamically example and take a look at how custom annotation is implemented there. Actually, it acts like a plain ContentControl, so you need to place the desired layout as its content.

Please, try it and let us know if you need any assistance,

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.