Still trying to find good example of the more complex MVVM scenarios...
Suppose I have one viewmodel - PlayersViewModel that has a collection of Players. In one view I see the collection of Players and add/edit/delete.
Another view is teams, where I assign Players to Teams. So I have another viewmodel - TeamsViewModel. This view also needs a collection of Players. How do I keep the two player lists in sync so changes are shown in both views?
I see a number of options:
- Add a reference to PlayersViewModel to my Team view (as well as a reference to TeamsViewModel) and use the PlayersViewModel.Players collection in both views
- Have two different collections that reference the same underlying collection instance (somehow)
- Create a static property on the Player model like Player.All that returns the collection and the viewmodels manage Players by Player.Add(player), Player.Delete, etc. instead of PlayersViewModel.AddPlayer(player)?
I tend towards #1 at the moment and using app-wide resources so the Team view can call both viewmodels. But then how do I use the selected Players in my PlayersViewModel.Players collection in my TeamsViewModel to add them?
Help please!!