However, I ran into a problem when a confirmation was required from the user before removing an entity chosen by the user. The command responsible for the removal behavior was triggered from within the View and executed from within the ViewModel. In my opinion, the ViewModel should not directly use any presentation functionality (e.g. showing a MessageBox
). In my quest to find a reasonable solution on the web, I ran into the following solutions:
- Just show the messagebox from the ViewModel.
- Use a solution that adds extra code to the View which reacts to a trigger from the ViewModel
.
- Bind the View to a message property and have it show a messagebox when this changes.
- Use one of the available MVVM frameworks and use the solution they provide.
Because I was unable to find a solution matching my requirements, I came up with the solution as described in this linked article on CodeProject.