cwensley / Portable.Xaml

Portable .NET library for reading/writing xaml files.
Other
157 stars 39 forks source link

Add support to serialize custom markup extensions #143

Open Aminator opened 5 years ago

Aminator commented 5 years ago

Currently you can only deserialize custom markup extensions and in my case I would really like to be able to serialize them to avoid messy string handling.

There could be two approaches to this:

  1. Make XamlServices behave like System.Windows.Markup.XamlWriter, which not only tries to convert anything with a TypeConverterAttribute to a string but also a MarkupExtension. You can read this blog post for more details.
  2. Extend the XamlObjectReader by allowing nested readers with a different type, which in this case would be a custom markup extension. I tried this approach by deriving from XamlObjectReader and having a nested XamlObjectReader for the custom markup extension, but I faced issues concerning namespaces.