Hi,
I’m creating a CustomChartModifier which I am able to hook to a SciStockChart (a template item in a SciChartGroup MVVM) and now I’m having difficulties in adding the BoxAnnotation to the Chart.
This is the code I’m using in my ChartModifier and placing a breakpoint shows me that indeed the code runs through this method, however, I do not see any BoxAnnotation on my chart? I’ve even tried adding the Height and Width properties without any further success. Other CustomModifiers to draw Lines and Ellipses works without problems. Do BoxAnnotations work differently?
I’m looking to have the the user be able to draw a BoxAnnotation on the chart, free hand / dynamically.
SimpleBoxAnnotationModifier.cs
public override void OnModifierMouseDown(ModifierMouseArgs e)
{
base.OnModifierMouseDown(e);
var resources = new AnnotationStyles();
// x:Key="BoxAnnotationStyle" TargetType="s:BoxAnnotation"
var style = (Style)resources["BoxAnnotationStyle"];
_annotationCreation = new AnnotationCreationModifier () { AnnotationType = typeof(BoxAnnotation), AnnotationStyle = style };
this.ModifierSurface.Children.Add(_annotationCreation);
}
AnnotationStyles.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
x:Class="ChartModifierBinding.AnnotationStyles">
<Style x:Key="BoxAnnotationStyle" TargetType="s:BoxAnnotation">
<Setter Property="BorderBrush" Value="#279B27"/>
<Setter Property="Background" Value="#551964FF"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="IsEditable" Value="True"/>
</Style>
Thanks for any pointers or tips!
- David T asked 9 years ago
- last active 8 years ago