How can I do this?
Tried using a TypeConverter, but the only thing I could think of was to construct the XML for the types, which doesn't quite cut it. TypeConverters in xaml serialization will escape xml and treat it like plain text. Value converters aren't much better.
Now, I'm moving to ISupportInitialize and will throw if changes are made after initialization, but I would have liked the immutable route...
Example of a type I wish to serialize:
public struct Foo
{
public string Bar {get;private set;}
public Foo(string bar) : this()
{
Bar = bar;
}
}
and the code
var foo = new Foo("lol");
var serializedFoo = XamlWriter.Save(foo);