开发者

Xaml Serialization

开发者 https://www.devze.com 2023-04-03 05:05 出处:网络
I want to use xaml serialization to store the configuration data of my application. This info is represented as readonly properties of a custom configuration class. When loading the application, the c

I want to use xaml serialization to store the configuration data of my application. This info is represented as readonly properties of a custom configuration class. When loading the application, the configuration class is deserialized through xamlservices api from a text file. However, I get an error in the form: Cannot set unknown member 'property_name'.' Line number '24' and line position '4'. This is because the setters are private. Is there a way to deserialize the obj开发者_StackOverflowect with readonly properties through xaml?


Yes, but you won't get round-trip serialization. You write a XAML document in which the object you want is created using a non-default constructor.

Look up info about the directive.


If its a collection property you can try using the ContentWrapperAttribute. You can also look at the ValueSerializerAttribute

More info can be found here http://msdn.microsoft.com/en-us/library/ff354959.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号