“Are you sure?” prompts. Part of the ViewModel or purely the view?

The prompts should definitely not be part of the ViewModel, but this doesn’t necessarily mean that the best solution is to hardcode them in the View (even though that’s a very reasonable first approach).

There are two alternatives that I know of which can reduce coupling between View and ViewModel: using an interaction service, and firing interaction requests. Both are explained very well here; you might want to take a look.

The general idea is that you abstract how asynchronous interactions are done and work with something more similar to event-based logic while at the same time allowing the ViewModel to express that it wants to interact with the user as part of an operation; the net result is that you can document this interaction and unit test it.

Edit: I should add that I have explored using Prism 4 with interaction requests in a prototype project and I was very pleased with the results (with a bit of framework code going you can even specify what’s going to happen on a specific interaction request entirely in XAML!).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)