Hi,
I need to serialize to an xml file the properties changed in the appearances of some infragistics controls.
Could someone post some code to serialize an appearance object, thxs!!
On some controls, such as the grid, there are SaveAsXml and LoadFromXml methods that will accomplish this for you. For other controls, you would basically have to roll your own solution. Since the Appearance objects implement ISerializable, you can do this with a SoapFormatter. I just whipped up a quick example of saving just the Appearance property, but you could add as many entries as you want for the various dictionary keys:
private void ultraButton1_Click(object sender, EventArgs e){ using (FileStream stream = new FileStream("Appearance.xml", FileMode.Create)) { SoapFormatter formatter = new SoapFormatter(); ObjectStreamer streamer = new ObjectStreamer(); streamer.Dictionary.Add("Appearance", this.ultraButton1.Appearance); formatter.Serialize(stream, streamer); }}private void ultraButton2_Click(object sender, EventArgs e){ using (FileStream stream = new FileStream("Appearance.xml", FileMode.Open)) { SoapFormatter formatter = new SoapFormatter(); formatter.Binder = new Binder(); ObjectStreamer streamer = formatter.Deserialize(stream) as ObjectStreamer; this.ultraButton2.Appearance = ((SerializationEntry)streamer.Dictionary["Appearance"]).Value as AppearanceBase; }}
-Matt