Pre loader

Serialization of Custom Annotation

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

How do I serialize custom annotation, as I am not able to serialize using Annotation collection as it only serializes the iAnnotation properties and not extended properties like TEXT.

Version
sciChart 4.x
  • You must to post comments
0
0

Hello Selva Arun,

all annotations including CustomAnnotations are derived from AnnotationBase which implemets an IXmlSerializable interface methods like WriteXml() and ReadXml() all you have to do is to override those methods in your CustomAnnotation

public class MyExtendedCustomAnnotation : CustomAnnotation
{
    public override void WriteXml(XmlWriter writer)
    {
        base.WriteXml(writer);
    }

    public override void ReadXml(XmlReader reader)
    {
        base.ReadXml(reader);
    }
}

Best Regards,
Pelyushkevych Nazariy
SciChart Wpf\Xamarin developer

  • You must to post comments
0
0

Hello Selva Arun

1) ” I set the type of CustomAnnotation to this extendedtype” you mean this MyExtendedCustomAnnotation ? it’s just a name
2) “Do I need to add the extended properties in the above extended class? It still doesn’t serialise.” — if you use Custom annotation and have there your custom properties you have to serialize them manually by yourself. This means you have to convert your properties to string and write it to your writer, something like this ===>>> writer.WriteAttributeString(propertyName, value); and then just read it like

var value = reader[propertyName];

3) If you still have problems with that serialization, you can create a sample app and attach it here, and probably i’ll try to find solution for you.

  • You must to post comments
0
0

Do I need to add the extended properties in the above extended class? It still doesn’t serialise.

I set the type of CustomAnnotation to this extendedtype.

Please let me know. What else do I need to do?

  • You must to post comments
Showing 3 results
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