日期:2014-05-17 浏览次数:20912 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
namespace ConsoleApplication1
{
class A
{
public string Name { get; set; }
}
class AReadOnlyObservableCollection : ReadOnlyObservableCollection<A>
{
public AReadOnlyObservableCollection(ObservableCollection<A> list) : base(list)
{
}
protected override void OnPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args)
{
Console.WriteLine("change: " + args.PropertyName);
}
}
class Program
{
static void Main(string[] args)
{
ObservableCollection<A> list = new ObservableCollection<A>();
AReadOnlyObservableCollection rolist = new AReadOnlyObservableCollection(list);
list.Add(new A() { Name = "aa" }); //list更改通知rolist。
}
}
}