I have figured out that my concept was incorrect.
Actually, I did not think through the whole process of updating.
Well the UI is bounded to an object inside an
ObservableCollection via the
Path. The UI is updated via two routes (I was thinking only one) via the
ObservableCollection as a result of changes on this object (add,remove, etc.) and via changes in the item (if the item implements
INotifyPropertyChanged).
I was thinking that "magically" the
ObservableCollection is notified that an internal item was changed and then it notifies the UI which then goes via the
Path and reads the new value from the item.
But Actually the
ObservableCollection is out of the picture and someone has to invoke the
set command of the item (property) which then invokes the OnPropertyChanged (as implemented in
ViewModelBase.cs) and then the UI invokes the
get.
public int Item
{
get { return mItem; }
set
{
mItem= value;
OnPropertyChanged("Item");
}
}
Who is this someone: well it could be another property which is binded to another UI (eg button,slider) and then call the
set from within its
set. Or, as I did in case of changes in the Mosel itself (some communication going on there) is by implementing a
DispatcherTimer which periodically reads a parameter in the model and updates the property which notifies the UI.
It is true that I could implement an event notification from the Model to the ModelView but it just does not sound to me MVVM (which I am trying to follow).
Igal