【发布时间】:2010-10-31 18:45:37
【问题描述】:
我对 MVVM 有点陌生。我不确定最好的方法是做我想做的事。
这是场景:
我有一个要显示另一个窗口的虚拟机。我可以打电话给myNewWindowView.Show(),但首先我需要在我的新窗口的虚拟机中设置一些数据。
我应该将 myNewWindowView 和 NewWindowViewModel 都暴露给调用 ViewModel 吗?
这是一个例子:
class MainVM
{
public void FindCustomer(string nameParial)
{
List<Customer> customers = ServiceCall.GetCustomers(nameParital);
// This is the part I am not sure how to do. I am not sure if this
// View Model should have a reference to a different view model and
// the view too.
myNewWindowViewModel.CustomerList = customers;
myNewWindowView.Show();
}
}
【问题讨论】: