如何使用windowmanager caliburn micro wpf在ViewModels之间传递对象

时间:2016-02-25 08:32:28

标签: wpf caliburn.micro window-managers

我与AddEditViewModelAddEditView相关联。我想使用ViewModel2对象从IWindowManager启动对话框窗口。来自ViewModel2 class的代码:

windowManager.ShowDialog(new AddEditViewModel(_windowManager,_events), 
this.SelectedCar, settings);

但我不知道如何恢复this.SelectedCar中的对象AddEditViewModel?有可能吗?

1 个答案:

答案 0 :(得分:1)

您可以在显示对话框后访问该对象:

var model = new AddEditViewModel(_windowManager, _events);

dynamic settings = new ExpandoObject(); 
settings.WindowStyle = WindowStyle.ToolWindow; 
settings.ShowInTaskbar = true; 
settings.Title = "This is a custom title";

var result = windowManager.ShowDialog(model, null, settings);

var car = model.SelectedCar;