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.
- kelias asked 1 year ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 1 year ago
- You must login to post comments
Please login first to submit.