Pre loader

BindableCollection TextAnnotationViewModel to AnnotationCollection casting

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

0
0

Hi All,

I am new to SciChart world and need little assistance. I have to export scichart to image(format not matter right now). I am using WPF with MVVM. I have created a scichartsurface object in my viewmodel and now tryng to assign different properties that are bind to my actual scichartsurface in View. I am facing type casting error while assigning annotation preperty.

Here’s I define Annotation bind to actual graph in view

     public BindableCollection<TextAnnotationViewModel> GraphAnnotations;

here’s the code for where I am getting type mismatch error

    private void ChartToImage()
    {
        var chart = new SciChartSurface()
        {
            RenderableSeries = new RenderableSeriesSourceCollection(LineRenderSeries)
            Annotations = GraphAnnotations,
        };
    }

Here’s my View code

    <s:SciChartSurface
        Name="sciChart"
        Annotations="{s:AnnotationsBinding GraphAnnotations}"
        RenderableSeries="{s:SeriesBinding LineRenderSeries}">

It would be great if you also give example and details for X,Y Axis casting for my above ChartToImage method.

Version
v5
  • You must to post comments
0
0

I dont know its the right way or not but still I manage to resolve this issue by below code.

            var annotationCollection = new AnnotationCollection();
            foreach (var graphAnnotation in GraphAnnotations)
            {
                var annotation = new TextAnnotation();
                annotation.X1 = graphAnnotation.X1;
                annotation.Y1 = graphAnnotation.Y1;
                annotation.Text = graphAnnotation.Text;
                annotationCollection.Add(annotation);
            }
  • 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