Passing messages between viewmodels

I have one viewmodel which performs an action and when this action is performed ui in view of some other viewmodel must be disabled. My question is who should be responsible for the disable? Should I call from first viewmodel to second something like disable method. Or should first viewmodel just fire an event, that action was performed and the second viewmodel will handle that event and disable the ui?

Answers 1

  • If this is in Decoupled viewmodals then se Messaging or some sort of event aggregation that is suitable for decoupled viewmodals otherwise use references or events when you create the view modals. This is totally up to you

    If you are using MVVM light Send a Message to who ever needs it. if you are using Prism use Event Aggregation. If you have creation over both viewmodals why not just an action or even or a reference

    Who should do this and why? it totally depends up to how much OCD you have, who has major concern over the functionality, and what is the most maintainable and logical to work out.


Related Articles