实际问几个ObservableCollection的CompositeCollection

时间:2014-09-10 08:42:00

标签: c# wpf entity-framework observablecollection compositecollection

我刚刚发现了CompositeCollection类,并且声音能够将多个ObservableCollections重组为一个。

我对它是如何工作有疑问。我有来自Entity Framework创建的几个表的4 ObservableCollections。这4个表有一些具有相同名称的列。例如,我们在4个表中找到一个名为OTM的列,在3个表中找到Numero等等。当我绑定CompositeCollection时,这可能是个问题吗?

对不起,如果我感到困惑,请不要犹豫要求提供更多信息,我可以更新我的帖子。

修改1:

这是我的ViewModel类,我在其中声明了几个ObservableCollections和CompositeCollection:

class ViewModel:INotifyPropertyChanged
{
    private BDDInterneEntities _BDDInterneEntities;

    public ViewModel()
    {
        _BDDInterneEntities = new BDDInterneEntities();
        ResultatCollection = new ObservableCollection<Resultat>(_BDDInterneEntities.Resultat);
        D98EquipementsCollection = new ObservableCollection<D98Equipements>(_BDDInterneEntities.D98Equipements);
        D98DetailsCollection = new ObservableCollection<D98Details>(_BDDInterneEntities.D98Details);
        D675Collection = new ObservableCollection<D675>(_BDDInterneEntities.D675);

        CollectionContainer cc1 = new CollectionContainer();
        CollectionContainer cc2 = new CollectionContainer();
        CollectionContainer cc3 = new CollectionContainer();
        CollectionContainer cc4 = new CollectionContainer();
        cc1.Collection = ResultatCollection;
        cc2.Collection = D98EquipementsCollection;
        cc3.Collection = D98DetailsCollection;
        cc4.Collection = D675Collection;
        cmpc.Add(cc1);
        cmpc.Add(cc2);
        cmpc.Add(cc3);
        cmpc.Add(cc4);
    }

    public ObservableCollection<Resultat> ResultatCollection { get; set; }
    public ObservableCollection<D98Equipements> D98EquipementsCollection { get; set; }
    public ObservableCollection<D98Details> D98DetailsCollection { get; set; }
    public ObservableCollection<D675> D675Collection { get; set; }
    public CompositeCollection cmpc {get; set; }

    public event PropertyChangedEventHandler PropertyChanged;

    private void OnPropertyChanged(string property)
    {
        if(PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
    }
}

0 个答案:

没有答案