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("{0}Style", type.Name); CustomVerticalLineAnnotation HAnot = new CustomVerticalLineAnnotation(); HAnot.Name = "VAnot1"; HAnot.YAxisId = "GenYAxis"; // HAnot.YAxisId = "GenYAxis"; 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["VerAnnotLabelTemplate"]; 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)} };
- bochelie asked 10 years ago
- You must login to post comments
Please login first to submit.