In all the examples on the video sessions or web articles that I have found, a simple disconnected scenario is given as a example. I am struggling with how to implement refreshing of the shared data using MVVM Light, without relying on View's initialized
event and code behind.
This scenario is a very common scenario, and example would look like this:
CategoryView -> CategoryViewModel
ProductView -> (ProductViewModel, CategoryViewModel) - needs data from CategoryViewModel in order to assign a product to a category.
We can have both CategoryView and ProductView showed on screen, and both of them needs to reference same categories collection, in order for INotifyCollectionChanged and INotifyPropertyChanged to do the synchronization task between the views. This means
that CategoryViewModel must be shared (single instance), otherwise two separate collections of categories would exist.
With this scenario how can we issue a request for the fresh data from the service to be loaded? CategoryViewModel is created only once, ProductViewModel also, since we will need products collection on some other screen.