[英]mvvmcross iOS Bind to list Cannot convert `lambda expression' to non-delegate type `string'
I worked this out but I want to share because there doesn't seem to be an answer on SO or elsewhere. 我已经解决了这个问题,但我想分享,因为在SO或其他地方似乎没有答案。
My ViewModel has a list of models eg 我的ViewModel包含模型列表,例如
private List<string> _people;
public List<string> People
{
get { return this._people; }
set { this._people = value; RaisePropertyChanged (() => People); }
}
When I try to bind to set.Bind the MvxStandardTableViewSource, the evil error above prevents compile: 当我尝试绑定到set.Bind MvxStandardTableViewSource时,上面的错误错误阻止了编译:
var source = new MvxStandardTableViewSource(tableView, "People");
tableView.Source = source;
var set = this.CreateBindingSet<FirstView, Core.ViewModels.FirstViewModel>();
set.Bind(source).To(vm => vm.People);
Cannot convert lambda expression' to non-delegate type
string' 无法将lambda expression' to non-delegate type
转换lambda expression' to non-delegate type
字符串
The solution is to add a reference to your models library. 解决方案是添加对模型库的引用。 Simple right? 简单吧? But not obvious because you don't have to do this for other mobile projects - Probably because iOS is doing compile time binding. 但这并不明显,因为您不必为其他移动项目执行此操作-可能是因为iOS正在执行编译时绑定。
The solution is to add a reference to your models library. 解决方案是添加对模型库的引用。
Any type being bound in the iOS view has to have its assembly referenced by the iOS project.. iOS视图中绑定的任何类型都必须由iOS项目引用其程序集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.