这是关于这个主题的进一步问题:如何使用反序列化对象? 我在我的类中遇到了一些变量的问题,现在我只是在不能被序列化的变量前面加上
我的类看起来像这样:
现在我需要序列化Bitmapimage和SolidColorBrush,以便将这些信息传递到我的下一个视图。我找到了一种方法(参见Serialize a Bitmap in C#/.NET to XML),但这对于Windows 8应用程序不起作用。在Windows 8中不可用System.Drawing.Bitmap。请问有人能帮我解决这个问题吗?谢谢!
[XmlIgnore]
,所以目前类的序列化可以工作。我的类看起来像这样:
public class Channel : INotifyPropertyChanged
{
public int Width { get; set; }
public int Height { get; set; }
[XmlIgnore]
public BitmapImage Logo { get; set; }
public string CurrentCoverURL { get; set; }
[XmlIgnore]
public SolidColorBrush Background { get; set; }
private string name;
public string Name
{
get { return name; }
set
{
name = value;
NotifyPropertyChanged("Name");
}
}
}
现在我需要序列化Bitmapimage和SolidColorBrush,以便将这些信息传递到我的下一个视图。我找到了一种方法(参见Serialize a Bitmap in C#/.NET to XML),但这对于Windows 8应用程序不起作用。在Windows 8中不可用System.Drawing.Bitmap。请问有人能帮我解决这个问题吗?谢谢!
bitmapImage
中的数据似乎并没有被读取。只有它的尺寸被查询以创建一个新的WriteableBitmap
,然后你将刚刚创建的WriteableBitmap
保存到一个字节数组中,但实际上你并没有读取bitmapImage
中的数据。 - Mark A. Donohoe