Lets say we have a derivided class "SerializableLabel" from the base class "System.Windows.Controls.
[XmlRoot("SerializableLabel")]
public class SerializableLabel : Label
{
public string foo = "bar";
}
I'd like to serialize this class but ignore ALL of the properties in the parent class. Ideally the xml would look something like:
<SerializableLable>
<foo>bar</foo>
</SerializableLable>
How is this best achieved?
My first attempt used the typical XmlSerializer approach:
XmlSerializer s = new XmlSerializer(typeof(SerializableLabel));
TextWriter w = new StreamWriter("test.xml");
s.Serialize(w, lbl);
w.Close();
But this raises an exception because the serializer attempts to serialize a base class property which is an interface (ICommand Command).