Changing an association property (EntityCollection) does not increase the PropertyChanged property

I want to bind some readonly DataGrid column data to the Association Entity via Converter property (convert the collection from this association property to a string). When I try to add / remove items from the collection, the binding does not work. PropertyChanged is also not growing.

contractPosition.PropertyChanged += (s, e2) =>
    {
           a = 0;//don't fire
    };

contractPosition.ContractToOrderLinks.Remove(link);

Here is a fragment of entityPosition Entity (generated by EF4):

[Association("ContractPosition_ContractToOrderLink", "PositionId", "ContractPositionId")]
        [XmlIgnore()]
        public EntityCollection<ContractToOrderLink> ContractToOrderLinks
        {
            get
            {
                if ((this._contractToOrderLinks == null))
                {
                    this._contractToOrderLinks = new EntityCollection<ContractToOrderLink>(this, "ContractToOrderLinks", this.FilterContractToOrderLinks, this.AttachContractToOrderLinks, this.DetachContractToOrderLinks);
                }
                return this._contractToOrderLinks;
            }
        }

Why is PropertyChanged not growing? How can I implement a binding update?

+2
source share
1 answer

There are several different events to listen to:

  • INotifyPropertyChanged.PropertyChanged

    , _contractToOrderLinks. , , .

  • INotifyCollectionChanged.CollectionChanged

    , , , .

  • EntityCollection<>.EntityAdded

    .

  • EntityCollection<>.EntityRemoved

    , . , , .

INotifyCollectionChanged.CollectionChanged. , EntityCollection<> , . :

((INotifyCollectionChanged)contractPosition.ContractToOrderLinks).CollectionChanged += (s, e) =>
    {
           a = 0; //does fire
    };

contractPosition.ContractToOrderLinks.Remove(link);
+1

All Articles