I need a simple example on how to make one viewmodel update a property on another viewmodel.
Here’ is the situation. I got a view and viewmodel responsable fo displaying a list of albums. I got another view and viewmodel responsable for added a new albums ( couple of textboxes and a button ) now when the new album gets added how do I tell the Collection in the other view that the a new album has been added to it?
I read about frameworks that can do this for me, but Im trying to learn so I won’t use a framework for the being..
There several ways:
1)
AlbumsVMis aware ofCreateAlbumVM(for example first opens the second). In this case you can simply add album intoAlbumsVMusing details provided byCreateAlbumVM2)
CreateAlbumVMis aware ofAlbumsVM. Then it can insert albums intoAlbumsVMitself.3)
AlbumsVMreceives albums asObservableCollectionfrom somewhere. ThenCreateAlbumVMcan insert new album into originalObservableCollectionwhich will be reflected inAlbumsVM4) There is some mediator between these viewModels which provide event
AlbumWasAdded.