Pre loader

Is there a way to serialize just Annotations?

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

I need to serialize annotations. Not all the chart properties, but just Annotations.

I’ve tried to serialize the AnnotationCollection, as well as a List and neither works.

Version
6.6.0
  • You must to post comments
0
0

Hi Kelias,

All annotations implement IXmlSerializable so its possible to loop over the annotation collection and serialize them. Here’s a quick code sample of how to do that in C#

        // Serialize single annotation
        var ann = new TextAnnotation();

        var stream = new MemoryStream();
        var serializer = new XmlSerializer(typeof(TextAnnotation));
        serializer.Serialize(stream, ann);

        // Serialize AnnotationCollection
        stream = new MemoryStream();
        var annCollection = new AnnotationCollection()
        {
            new TextAnnotation(),
            new BoxAnnotation(),
        };
        serializer = new XmlSerializer(typeof(AnnotationCollection));
        serializer.Serialize(stream, ann);

Does that help?

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.