oibo8x / subsonicproject

Automatically exported from code.google.com/p/subsonicproject
0 stars 0 forks source link

ListChanged events not firing for ActiveCollections #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To enable ListChanged events for collection classes, please add v3 type
code to v2. Add INotifyPropertyChanging and INotifyPropertyChanged to
inheritance for generated table classes (ex: Product class in Northwind).
Then add additional lines to property setters.

set{
    this.OnProductNameChanging(value);
    this.SendPropertyChanging();
    this._ProductName = value;
    this.SendPropertyChanged("ProductName");
    this.OnProductNameChanged();
}

and then add event support:

private static PropertyChangingEventArgs emptyChangingEventArgs = new
PropertyChangingEventArgs(String.Empty);
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void SendPropertyChanging()
{
    if ((this.PropertyChanging != null))
        this.PropertyChanging(this, emptyChangingEventArgs);
}

protected virtual void SendPropertyChanged(String propertyName)
{
    if ((this.PropertyChanged != null))
        this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}

Original issue reported on code.google.com by parisolo...@yahoo.com on 30 Mar 2009 at 9:44

GoogleCodeExporter commented 9 years ago
I don't want to impose template enhancements at this point - only fixes. Thank 
you 
for the idea though!

Original comment by robcon...@gmail.com on 9 Apr 2009 at 3:29

GoogleCodeExporter commented 9 years ago
Perhaps you can add this to a FAQ so people can add it on their own. It is very
useful to have the events fire as intended. The list event won't work unless the
elements participate.

Original comment by parisolo...@yahoo.com on 9 Apr 2009 at 4:12