My application generates XAML files from in-memory objects using the built-in .NET solution: System.XamlServices.Save(Stream, Object)
However, the XAML I get is polluted badly. All properties are always serialized. Is there a way that to tell the XAML serializer to ignore properties that hold their default values? (I have almost full control over the classes that are serialized.)
Expression Blend solves this wonderfully: if we do not change a property, the generated XAML file will not contain it, at all. The resulted XAML is not cluttered with all the possible properties and their default values and does not look like the regular autogenerated mess. I would like to have beautiful XAML, too.
To do this with just one object:
Once:
For each object:
I had you same the XPath in the dictionary to make nested objects work better. It depends what your objects are and how they are nested for me to be able to speak to that, however. good luck!