How have you successfully implemented MessageBox.Show() functionality in MVVM?

Of the two you mention, I prefer option #2. The Delete button on the page just makes the "Confirm Delete Dialog" appear. The "Confirm Delete Dialog" actually kicks off the Delete Have you checked out Karl Shifflett's WPF Line Of Business Slides and Demos?

I know he does something like this. I'll try to remember where: karlshifflett.wordpress.com/2009/06/17/c... EDIT: Check out Demo #11 "Data Validation in MVVM" (EditContactItemsControlSelectionViewModel. DeleteCommand).

Karl calls a popup from the ViewModal (What!? :-). I actually like your idea better.

Seems easier to Unit Test.

Of the two you mention, I prefer option #2. The Delete button on the page just makes the "Confirm Delete Dialog" appear. The "Confirm Delete Dialog" actually kicks off the Delete.

Have you checked out Karl Shifflett's WPF Line Of Business Slides and Demos? I know he does something like this. I'll try to remember where: karlshifflett.wordpress.com/2009/06/17/c... EDIT: Check out Demo #11 "Data Validation in MVVM" (EditContactItemsControlSelectionViewModel.

DeleteCommand). Karl calls a popup from the ViewModal (What!? :-).

I actually like your idea better. Seems easier to Unit Test.

I finally solved this with solution #1. It doesn't pop up a window, just "inserts" a Border element at the top of the screen by triggering it from Visibility=collapsed to Visibility=Visible. I created the DelegateCommands: TurnOnDialogueBoxDelete, DeleteItem and CancelDialogueBoxDelete.

I created the ViewModelProperties: DialogueBoxDeleteStatus, ItemIdMarkedForDeletion, and DialogueBoxDeleteText. So it is not as easy as a simple MessageBox.Show() but it works nicely. I'm sure eventually some of this can be abstracted away for when other dialogue boxes are needed.

– Edward Tanguay Jul 8 '09 at 14:41 And it can be unit tested. :-) – Edward Tanguay Jul 8 '09 at 14:43.

Services to the rescue. Using Onyx (disclaimer, I'm the author) this is as easy as: public void Foo() { IDisplayMessage dm = this.View.GetService(); dm. Show(" world!"); } In a running application, this will indirectly call MessageBox.

Show(" world! "). When testing, the IDisplayMessage service can be mocked and provided to the ViewModel to do what ever you want to accomplish during the test.

Why not just do something really simple with Action and Func deanchalk.me.uk/post/WPF-MVVM-e28093-Sim....

This is by far the simplest solution I've seen. – JP Richardson Jun 7 '10 at 15:43.

I would just throw it from the VM. I don't want to have to use someone else's service or write my own just to throw a messagebox.

I've made a simple MessageBox wrapper control for us to use in pure MVVM solution and still allowing unit testing capability. The details are in my blog geekswithblogs.net/mukapu/archive/2010/0... mukapu.

I had a look at several of the suggestions here and would recommend looking at Mukapu's wrapper. This is very lightweight and keeps UI-specific code out of the ViewModel. Great stuff Mukapu!

I just create an interface (IMessageDisplay or similar) which gets injected into the VM, and it has methods like a MessageBox (ShowMessage() etc). You can implement that using a standard messagebox, or something more WPF specific (I use this one on CodePlex some guy called Prajeesh). That way everything's separated and testable.

I've implemented a Behavior that listens to a Message from the ViewModel. It's based on Laurent Bugnion solution, but since it doesn't use code behind and is more reusable, I think it's more elegant. Check it out here.

WPF & Silverlight MessageBoxes MVVM supported slwpfmessagebox.codeplex.com.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions