WPF(PropertyChangedEventManager)中数据绑定ObservableCollection的序列化

WPF(PropertyChangedEventManager)中数据绑定ObservableCollection的序列化,wpf,serialization,Wpf,Serialization,我试图通过数据绑定向Listbox显示一个列表。这是我的密码 [Serializable] public class RecordItem : INotifyPropertyChanged { //implements of INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; protected void Notify(string propName) { if

我试图通过数据绑定向Listbox显示一个列表。这是我的密码

[Serializable]
public class RecordItem : INotifyPropertyChanged
{
    //implements of INotifyPropertyChanged
    public event PropertyChangedEventHandler PropertyChanged;
    protected void Notify(string propName) { if (this.PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propName)); } }
}


[Serializable]
public class Records : ObservableCollection<RecordItem>
{
    public UOCRecords() { }

    public void Serialize(string path)
    {
        BinaryFormatter binForm = new BinaryFormatter();
        using (FileStream sw = File.Create(path))
        {
            binForm.Serialize(sw, this);
            sw.Close();
        }
    }

    public static UOCRecords Deserialize(string path)
    {
        //...
    }
}
并尝试执行序列化

this.myRecents.Serialize(recentsPath);
它失败,出现以下错误:

程序集“WPFAApplication1,版本=3.0.0.0,区域性=中性,PublicKeyToken=31bf3856ad364e35”中的类型“System.ComponentModel.PropertyChangedEventManager”未标记为可序列化

我该怎么处理呢

另外,我不想序列化PropertyChangedEvent处理程序。我想将[NonSerializable]属性标记为该属性,但我不知道如何标记该属性

我想将[NonSerializable]属性标记为该属性,但我没有 我知道怎么做

在这种情况下,只需使用
[字段:非序列化]
属性标记事件:

[field:NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
[field:NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;