Search code examples
xamlsavexaml-serialization

Ignoring non-serializable objects in XamlWriter.Save


I have a bunch of WPF controls that needs to be dumped to xaml. Some controls contain non-serializable objects stored in their's Tag property. I need to ignore them during saving Xaml, since I need layout itself, but XamlWriter.Save generates an error that states that they are not serializable.


Solution

  • To ignore a property add

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    

    Check out this article: http://blogs.msdn.com/b/mikehillberg/archive/2006/09/16/xamlwriter.aspx