Rocky Change Request - EditableRootListBase<T>Rocky Change Request - EditableRootListBase<T>
Old forum URL: forums.lhotka.net/forums/t/3148.aspx
FireGarden posted on Thursday, July 05, 2007
Rocky,
I am working with an EditableRootList using an Object implementing INotifyPropertyChanged.
EditableRootList listens for children INotify events and forwards the call to a list changed event.
Unfortunately I too would like to know about the root child's INotify event. I could hookup an event handler however it would be easier if EditableRootListBase<T> made a call to a virtaul method OnPropertyChanged(sender, e){
}
As follows:
private void Child_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
for (int index = 0; index < base.Count; index++)
{
if (object.ReferenceEquals(base[index], sender))
{
this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
break;
}
}
OnChildPropertyChanged(sender, e);
}
This would make it easy in my collection to deal with the property changed events from the kids
Further I will extend PropertyChangedEventArgs and pass contexul data up to make it easy for my RootList to keep track of calculations, summaries etc.
Thanks,
Rob FireGarden
FireGarden replied on Thursday, July 05, 2007
This kind of thing could be sent in my children INotifyPropertyChanged evet
public class CalculatePropertyChangedEventArgs<T> : PropertyChangedEventArgs
{
T _oldValue;
T _newValue;
public CalculatePropertyChangedEventArgs(string propertyName, T oldValue, T newValue) : base(propertyName)
{
_oldValue = oldValue;
_newValue = newValue;
}
public T OldValue
{
get { return _oldValue; }
}
public T NewValue
{
get { return _newValue; }
}
}
wurzulator replied on Friday, July 06, 2007
I take a more manual approach and do this:
_milestones = Milestones.GetInstance(dr);
Milestones.ListChanged += delegate(object sender, ListChangedEventArgs e)
{ PropertyHasChanged("Milestones"); };
in the DataPortal_Fetch method and
_milestones = Milestones.NewInstance();
Milestones.ListChanged += delegate(object sender, ListChangedEventArgs e)
{ PropertyHasChanged("Milestones"); };
in the DataPortal_Create method
FireGarden replied on Friday, July 06, 2007
I don't think you see what I am trying to do. Rocky subscribes to the INotifyPropertyChanged event on each of the kids but it never actually uses
PropertyChangedEventArgs e.
Further to this it doesn't make PropertyChangedEventArgs available to the class. It essentially just throws it away.
RockfordLhotka replied on Tuesday, May 27, 2008
Added a virtual OnChildPropertyChanged() method that is called when a PropertyChanged event is handled from a child of the list to the 3.5.1 code in svn.
Copyright (c) Marimer LLC