我正在努力寻找正确的方法来做到这一点。我有一个MyCollectionViewModel
包含MyViewModel
. 我将此绑定到一个视图MyCollectionView
,其中一个项目的选择绑定回MyCollectionViewModel
调用的命令OpenMyViewCommand
。到目前为止,一切都很好:
private MvxCommand<MyViewModel> _openMyViewCommand;
public ICommand OpenMyViewCommand
{
get {
_openMyViewCommand= _openMyViewCommand?? new MvxCommand<MyViewModel>(OpenMyView);
return _openSubViewCommand;
}
}
现在,当我触摸列表视图中的一个项目时,它将触发命令并调用将OpenMyView
所选方法传递MyViewModel
给方法的方法。现在的问题是,无论我尝试什么,我似乎都可以ShowViewModel
显示所选模型的视图。我尝试了各种各样的事情,但直觉上,我本来希望像这样非常简单的东西可以工作:
private void OpenMyView(MyViewModel item) {
ShowViewModel<MyViewModel > (item);
}
但是,当然不是。我收到如下所示的错误:
013-06-10 10:46:05.849 MyAppIPhoneUI[51198:c07] mvx: Warning: 5.83 Problem creating viewModel of type MyViewModel - problem MvxException: Failed to resolve parameter for parameter model of type MyModel when creating MyApp.Core.MyViewModel
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.GetIoCParameterValues (System.Type type, System.Reflection.ConstructorInfo firstConstructor) [0x00042] in /MvvmCross-3/CrossCore/Cirrious.CrossCore/IoC/MvxSimpleIoCContainer.cs:377
at Cirrious.CrossCore.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type) [0x00030] in /MvvmCross-3/CrossCore/Cirrious.CrossCore/IoC/MvxSimpleIoCContainer.cs:266
at Cirrious.CrossCore.Mvx.IocConstruct (System.Type t) [0x00006] in /MvvmCross-3/CrossCore/Cirrious.CrossCore/Mvx.cs:115
at Cirrious.MvvmCross.ViewModels.MvxDefaultViewModelLocator.TryLoad (System.Type viewModelType, IMvxBundle parameterValues, IMvxBundle savedState, IMvxViewModel& viewModel) [0x00004] in /MvvmCross-3/Cirrious/Cirrious.MvvmCross/ViewModels/MvxDefaultViewModelLocator.cs:27
013-06-10 10:24:11.330 MyAppIPhoneUI[50878:c07] mvx: Warning: 6.87 Exception masked MvxException: Failed to load ViewModel for type MyApp.Core.MyViewModel from locator MvxDefaultViewModelLocator
at Cirrious.MvvmCross.ViewModels.MvxViewModelLoader.LoadViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest request, IMvxBundle savedState, IMvxViewModelLocator viewModelLocator) [0x00023] in /MvxViewModelLoader.cs:46
知道这里发生了什么吗?我有一个MyView
从 MvxViewController 继承的类,但它没有被加载。