Pre loader

Text Annotation Content

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

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.

Try SciChart Today

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

Start TrialCase Studies