WPF MVVM: How do ViewModels communicate with each other? WPF MVVM: How do ViewModels communicate with each other? wpf wpf

WPF MVVM: How do ViewModels communicate with each other?


One way to have disconnected ViewModels communicate to each other is to use a publish / subscribe mechanism such as PRISMs EventAggregator. However, in a parent / child ViewModel relationship, I think it's fine for the parent to have direct knowledge and control over the child ViewModel.

Personally, I don't think composing a ViewModel out of other ViewModels is a bad practice. I do it all the time. I generally favor composition over inheritance in my ViewModels.


The ViewModels usually 'inherit' relationships from the Model. And it's not wrong to add a relation when it makes sense.

It's perfectly OK for a ViewModel to have a property referring to another ViewModel.