Here is WPF application consisting from 3 UserControls:
UserControl3 is a part of UserControl2 content. I keep MVVM during developing and using Prism.
I need to invoke custom class method (which is model in terms of MVVM) in UserControl3 from view-model of UserControl1. The restriction that service in UserControl3 can't be singleton. I suppose to do it one of the following way:
Using event aggregator from Prism.
UserControl1view-model is publisher andUserControl3model is subscriber. For this I'll need to create unique Id inWindowand pass it toUserControl1andUserControl3.Creating service instance in
Windowand pass it toUserControl1andUserControl3. ThenUserControl1just invoke method on this instance.WindowpassUserControl2instance toUserControl1. View-model inUserControl1will just invoke method ofUserControl2, which will invoke method ofUserControl3and so on.
It seems like 2 and 3 approaches violates MVVM. What will you prefer?

I need to invoke custom class method (which is model in terms of MVVM) in UserControl3 from view-model of UserControl1-- Why?