Problem serializing aCanvas to a file..
Hi everybody!
I've got a Silverlight project where an user can custuming a canva by adding some controls an photos on it.
Now I would like to save the canvas on a xaml file. But before i making some test.
For that, i using an asp web service (with soap) where a methode taking an object and convert it to a xaml string with XamlWriter.Save.
On Silverlight side, I have made an UserControl named TestSerialization whith [DataContract] attribute before it. In the control, I've got an canvas filled with a color. So, in the TestSerialization.g.cs file, i've put [DataMember] just before it.
here is now my Saving method on Silverlight-side :
NisinServiceProxy.NisinBaseWebServiceSoapClient npc = new Gestion_Canevas_beta_1.NisinServiceProxy.NisinBaseWebServiceSoapClient();
npc.SauvegarderCanevasXAMLCompleted += new EventHandler<Gestion_Canevas_beta_1.NisinServiceProxy.SauvegarderCanevasXAMLCompletedEventArgs>(npc_SauvegarderCanevasXAMLCompleted);
List<Type> lt = new List<Type>();
//lt.Add(typeof(Canvas));
lt.Add(typeof(TestSerialisation));
lt.Add(typeof(XmlWriter));
lt.Add(typeof(Canvas));
lt.Add(typeof(Stream));
DataContractSerializer dcs = new DataContractSerializer(typeof(TestSerialisation),lt);
s = Stream.Null;
XmlWriter xmlw=XmlWriter.Create(s);
try
{
dcs.WriteObject(xmlw, test); //=> test is a TestSerialisation object.............I've already try with just s(the stream) without xmlWriter but it's the same effect
npc.SauvegarderCanevasXAMLAsync(xmlw);
}
catch (InvalidDataContractException ex)
{
mlg.AfficherMessage(ex.Message);
}
here is the declaration of the elements:
[DataMember]
public Stream s = null;
public TestSerialisation test = new TestSerialisation();
I've work on this since 2 days and I doesn't find any exemple of it on the web, there is a lot of exemple on other context(WPF, ect..) but not in Silverlight with a web service...
Please help me!! I"m starting to get crazy! ^^