Tim Van Wassenhove home

Here is an example of a ViewModel that translates domain messages to view events:

class GameViewModel : INotifyPropertyChanged, IListener<boardChanged>
{
	public event PropertyChangedEventHandler PropertyChanged = delegate { };

	public GameViewModel()
	{
		var messageBus = ServiceLocator.MessageBus;
		messageBus.Subscribe<boardChanged>(this);
	}

	void IListener<boardChanged>.Handle(BoardChanged message)
	{
		PropertyChanged("Board");
	}
}