【发布时间】:2015-09-18 12:23:51
【问题描述】:
我是 MVVM 的新手,我正在关注 MVVM Light 工具包。 为了实现消息框功能,我搜索并得到了这个example
我不明白的点是
- 类DialogService是我们应该通过继承IDialogService来创建的??
如果在继承接口后的类中是这种情况,我们需要编写如下内容
public Task<bool> ShowMessage(string message, string title, string buttonConfirmText, string buttonCancelText, Action<bool> afterHideCallback)
{
//Here a kind of this implemetation i need to do ?
//For example sake i didn't include the parameters.
MessageBox.Show();
}
如果上述情况在视图模型中为真,我们将 dialogServices.ShowMessage(prms....) ? 那么如何测试呢?
例如,如果它是 filebrowser ,如果我们按照理解在单元测试中调用这种方式,它将打开一个文件浏览器。 如何实现?
由于我对这种模式本身非常感兴趣,因此我很难理解。
请提供示例实现或任何参考。
编辑
我也提到了这个link。在评论中,它被告知其对视图的责任。 我更加困惑。一般来说,至少对于确认对话框,我们会怎么做?
谢谢。
【问题讨论】:
标签: c# wpf mvvm mvvm-light