问题描述:

I have an ObservableCollection that I want to save to a binary file. An item in that collection contains a field of a type System.Windows.Controls.Image so while saving I'm getting an error:

Type 'System.Windows.Controls.Image' in Assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.

I think I could try to convert an Image source to a byte[] variable and save it but I'd like to also save some Image properties like event handlers that I added or Effects.

It there any easy way to do it? or is it even possible?

网友答案:

convert that image to memory stream go through these links

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/dee0e287-b345-4e01-888a-ecfb9c3f40b0/

http://social.msdn.microsoft.com/forums/en-US/Vsexpressvcs/thread/011c2c24-ffc5-4be5-883b-2430267b33c8

网友答案:

You would need to provide your own serialization surrogate via the SurrogateSelector. What that serialization surrogate does is entirely up to you.

相关阅读:
Top