How do you display MessageBox from Business Logic without breaking MVVM?

Topics: Prism v4 - WPF 4
Mar 19, 2013 at 8:26 PM

My team are currently working on a project which exposes us to Prism for the first time.

In our Business Logic Layer (the model), we have a need to display Confirmation and Warning message boxes that require user interaction before the business logic code can proceed.

I know the View Model would normally handle this but in our particular case there are some scenarios where we can't avoid having to popup a message box from within the business logic.

What is the correct mechanism for displaying message boxes from within the business logic without breaking the MVVM rules?

Kind Regards,
Mar 20, 2013 at 4:20 PM

Based on my understanding of your application, a correct way to display message boxes from your Model could be:
  1. Create an event in your Model to alert the ViewModel when a situation that requires user interaction arises.
  2. In your ViewModel, use InteractionRequest<T> in order to handle the display of the message box.
You can find more the information about how to implement InteractionRequest<T> here:
Hope this helps,

Federico Martinez