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 Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

1
0

Hi,

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">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <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>
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
</Style>

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
0
0

Hi,

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,
Yuriy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.