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

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.