I use DataContract with ObservableCollection:
[DataContract(Namespace = Terms.MyNamespace)]
public class MyContract
{
internal MyContract ()
{
List = new ObservableCollection<string>();
}
[DataMember]
private ObservableCollection<string> list;
[XmlArray("list")]
public ObservableCollection<string> List
{
get
{
return list;
}
set
{
list = value;
list.CollectionChanged += (s, e) =>
{
Console.WriteLine("It is never happens!! Why?");
};
}
}
...
So, when I work with my collection like this.
MyContract contract = new MyContract();
contract.List.Add("some");
Item was been added but CollectionChanged event not fired.
Why?