-2

可能重复:
使用 MVVM 处理 WPF 中的对话框

我对如何实施以下内容有严重疑问。

  1. 从视图执行绑定到我的 ViewModel 的操作
  2. 根据条件,向用户发出请求

现在我为此目的使用 System.Windows.MessageBox.Show,我不知道这是否合适并且还希望有一个自定义对话框。

可以帮助我解决这个问题的技术或模式

4

1 回答 1

0

Firstly, if you are doing MVVM, then you should be using an MVVM framework. With Caliburn.Micro for example you could either display another window (using the window manager), or display a part of the existing view over the top of the other elements within the view.

Either way, if you want to stick with a message box, then you'll want to work against an abstraction in your view model, so that you can unit test your view models without the tests producing dialogs that wait on user input.

于 2012-09-15T20:52:24.880 回答