How to clone a chart object?

Apr 11, 2011 at 8:21 PM

Hi does anybody know how to clone a chart object (deep copy)..

I tried this method using XamlReader and XamlWriter,

  public Chart DeepCopy(Chart element)
            string shapestring = XamlWriter.Save(element);
            StringReader stringReader = new StringReader(shapestring);
            XmlTextReader xmlTextReader = new XmlTextReader(stringReader);
            Chart DeepCopyobject = (Chart)XamlReader.Load(xmlTextReader);
            return DeepCopyobject;


But it is running in to "Stack Overflow Exception"  at this first line of function - string shapestring = XamlWriter.Save(element); (seems like the get/set functions of axes and series properties are called recursively)..

Is there any other way to deep copy the WPF toolkit's chart object?

Thank You!