alpha-mouse
alpha-mouse

Reputation: 5003

Keep track of modifications in the objects tree

My WPF application shows a tree of objects having some properties. These properties can be modified from the UI via data bindings. Objects themselves can be added or deleted. Nothing special.

The question is: What's the best way to be aware of changes somewhere in the objects tree?

Ideas considered so far:

They all look like ugly mesh, so I'm afraid to implement anything of them.

Upvotes: 1

Views: 332

Answers (2)

alpha-mouse
alpha-mouse

Reputation: 5003

In case, comeone will be ever interested, I ended up subclassing all my objects in the tree from the common ancestor responsible for tracking IsDirty state and promoting it up and down the tree of objects. I mean that if some object is marked as dirty then all it's parents are considered dirty too. And yes, I implemented INotifyPropertyChanged in this common superclass to be aware of the changes.

Upvotes: 0

Matthew Abbott
Matthew Abbott

Reputation: 61599

INotifyPropertyChanged is probably the best way to go, as it would allow you to bubble up change notifications from any root node. I guess it would also depend how complex your types are, and what sort of changes you want to react to?

Upvotes: 2

Related Questions