Caliburn Micro : passing Object between ViewModel

牧云@^-^@ 提交于 2019-12-06 11:51:19

In the constructor TransporterCrudViewModel class you have:

this.InitializeTransporterForm(Parameter);

where Parameter is a property of type Transporter not initialized and you will call the method InitializeTransporterForm with a null parameter. Then you'll call SetUpForm method with a null value of the parameter Transporter t. I think you should initialize in some way this property.

Then, supposing you're continuing in your TransporterListViewModel class with this:

transporterCrudPageViewModel.InitializeTransporterForm(args.Parameter as Transporter);

in the method InitializeTransporterForm, you don't set the passed parameter as value of the property Parameter with something like this:

public async void InitializeTransporterForm(Transporter enumerable)
{
     TransporterFormVM = new TransporterFormViewModel(navigationService, enumerable);
     this.Parameter = enumerable; //setting the Parameter property..
     await SetUpForm(enumerable);
}

Beside these notes, you should put a breakpoint with your IDE in the line

transporterCrudPageViewModel.InitializeTransporterForm(args.Parameter as Transporter);

Make sure that the property Parameter of the NavigationEventArgs object is not null.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!