Print Page | Close Window

Child-Parent notifications.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3563
Printed Date: 19-Sep-2025 at 2:26am


Topic: Child-Parent notifications.
Posted By: rbautistaole
Subject: Child-Parent notifications.
Date Posted: 31-Jul-2012 at 6:35pm
Hi.
Which is your suggestion to resolve the next problem.
I have an Order and OrderDetail entities.
class Order
{
..
public RelatedEntityList<OrderDetail> Details{ get {return null}};
public decimal Total
{
get { return this.Details.Sum(Amount);
}
}
 
class OrderDetail
{
public decimal Quantity..
public decimal Price..
public decimal Amount...
}
 
Now, when the Amount of OrderDetail change i need to raise an PropertyChanged of Order.Total to make the GUI refreshed, i need some notification from the OrderDetail to know about the change. I try to suscribe in the Order constructor to

Detalles.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Detalles_CollectionChanged);

and suscribe to each OrderDetail PropertyChanged event to receive notifications about the changes, but it is not working.
 
How do you resolve this problem?
 



Replies:
Posted By: sbelini
Date Posted: 02-Aug-2012 at 11:36am
Hi rbatistaole,
 
The CollectionChanged event will be triggered only if the collection itself changes (i.e. an OrderDetail is added or removed to the collection).
I'd suggest to instead listen to the property changed event on the OrderDetail EntityGroup. There, you'd add some logic to locate the parent Order of the OrderDetail changed and would manually raise the PropertyChanged on the Order.
 
You can find more about EntityGroup events at http://drc.ideablade.com/xwiki/bin/view/Documentation/entity-events#HEntityGroupevents - http://drc.ideablade.com/xwiki/bin/view/Documentation/entity-events#HEntityGroupevents .
 
Regards,
   Silvio.



Print Page | Close Window