卡利微:的DialogResult [英] Caliburn Micro: DialogResult
问题描述
我无法找到以下问题的解决方案:
I can't find a solution for the following problem:
我打开的窗口管理一个对话框,卡利微:
I open a Dialog with the WindowManager from caliburn micro:
public void UserNew()
{
this._windowManager.ShowDialog(new UserViewModel(this._windowManager));
}
现在我需要的DialogResult当用户按OK按钮关闭对话框。窗口管理器的ShowDialog方法不返回的DialogResult ...
Now I need a DialogResult when the user close the dialog with the OK button. The ShowDialog method of WindowManager don't return a DialogResult...
谁能帮助我?
推荐答案
我倾向于使用视图模型来处理确定在对话框中发生了什么。例如,你可以有一个 IsCancelled
属性的 UserViewModel
您可以从<$ C $返回后询问C>的ShowDialog 电话。是这样的:
I tend to use the View Model to handle determining what happened in the dialog. For instance, you can have an IsCancelled
property on your UserViewModel
that you can interrogate after returning from the ShowDialog
call. Something like:
public void UserNew() {
var userViewModel = new UserViewModel(this._windowManager);
this._windowManager.ShowDialog(userViewModel);
if (userViewModel.IsCancelled) {
// Handle cancellation
} else {
// Handle other case(s)
}
}
这篇关于卡利微:的DialogResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!