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

后端 未结 12 1540
清歌不尽
清歌不尽 2020-11-28 05:55

I\'ve got a WPF application which calls MessageBox.Show() way back in the ViewModel (to check if the user really wants to delete). This actually works

12条回答
  •  忘掉有多难
    2020-11-28 06:53

    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 by Prajeesh).

    That way everything's separated and testable.

提交回复
热议问题