Search code examples
c#wpfserializabledependencyobject

Can a class derived from DependencyObject marked as serializable?


What des it mean by the following sentence

DependencyObjects are not marked as serializable 

To my knowledge, I can have a class which inherits from DependencyObject...and I can mark it as serializable. Anyway serialize property is not inheritable.

Could someone make me clear. Thanks in advance.


Solution

  • This means that a class that derives from DependencyObject cannot be serialized with standard serializers. As a workaround you could use XamlReader/XamlWriter as shown in this article.