Pre loader

style textformating

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

Hallo,

Once again I have a strange behaivour with the labeltextformating.

I have xaml code wich wont work. If i do the same in code behind it works perfectly. Why is that?

Code wich won’t work:

<Style x:Key="VerticalLineAnnotationStyle" TargetType="s:VerticalLineAnnotation">
            <Setter Property="Stroke" Value="#FFFF6600"/>
            <Setter Property="StrokeThickness" Value="2"/>
            <Setter Property="ShowLabel" Value="False"/>
            <Setter Property="LabelPlacement" Value="Axis"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="LabelTextFormatting" Value="dd MMM yyyy HH:mm:ss"/>
        </Style>

<s:SciChartSurface.Annotations>
               
                <pp:CustomVerticalLineAnnotation x:Name="FVert" YAxisId="GenYAxis" FontSize="12" ShowLabel="True" IsEditable="True" IsEnabled="True" Height="600"
                                          Style="{StaticResource VerticalLineAnnotationStyle}" IsHidden="True"/>


            </s:SciChartSurface.Annotations>

Code wich works:

internal void AddVerticalLineDiff(string annotationType)
        {
            var type = _annotationTypes[annotationType];
            var resourceName = String.Format(&quot;{0}Style&quot;, type.Name);

            CustomVerticalLineAnnotation HAnot = new CustomVerticalLineAnnotation();
            HAnot.Name = &quot;VAnot1&quot;;
            HAnot.YAxisId = &quot;GenYAxis&quot;;
            // HAnot.YAxisId = &quot;GenYAxis&quot;;
            HAnot.Style = (Style)Resources[resourceName];
            HAnot.DragDirections = XyDirection.XDirection;
            HAnot.Height = sciChart.RenderSurface.ActualHeight;
            HAnot.IsEnabled = true;
            HAnot.IsEditable = true;
            HAnot.ShowLabel = true;

            // Perform the hit test relative to the GridLinesPanel
            HitTestInfo hitTestInfo = sciChart.RenderableSeries[0].HitTest(new Point(0, 0));
            HAnot.X1 = hitTestInfo.XValue;

            //HAnot.AnnotationLabels[0].Template = (ControlTemplate)Resources[&quot;VerAnnotLabelTemplate&quot;];
            sciChart.Annotations.Add(HAnot);

        }
private readonly IDictionary<string, Type> _annotationTypes = new Dictionary<string, Type>()
        {
            { "LineAnnotation", typeof(LineAnnotation)},
            { "LineArrowAnnotation", typeof(LineArrowAnnotation)},
            { "TextAnnotation", typeof(TextAnnotation)},
            { "BoxAnnotation", typeof(BoxAnnotation)},
            { "HorizontalLineAnnotation", typeof(HorizontalLineAnnotation)},
            { "VerticalLineAnnotation", typeof(VerticalLineAnnotation)},
            { "AxisMarkerAnnotation", typeof(AxisMarkerAnnotation)}
        };
  • 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