简体   繁体   English

mvvmcross iOS绑定到列表无法将“ lambda表达式”转换为非委托类型“ string”

[英]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.

相关问题 无法将方法组“List”转换为非委托类型 - Cannot convert method group “List” to non-delegate type 无法将方法组“Read”转换为非委托类型“bool” - Cannot convert method group 'Read' to non-delegate type 'bool' 无法将方法组“ ToList”转换为非委托类型 - Cannot convert method group 'ToList' to non-delegate type 无法将方法组'FirstOrDefault'转换为非委托类型 - Cannot convert method group 'FirstOrDefault' to non-delegate type 无法使用反射将方法组转换为非委托类型 - Cannot convert method group to non-delegate type with reflection 无法调用非委托类型 - cannot invoke a non-delegate type 无法将方法组&#39;&#39;转换为非委托类型&#39;System.Delegate&#39;。 你打算调用这个方法吗? - Cannot convert method group '' to non-delegate type 'System.Delegate'. Did you intend to invoke the method? 无法将lambda表达式转换为类型“字符串”,因为它不是委托类型? - Cannot convert lambda expression to type “string” because it is not a delegate type? 无法将lambda表达式转换为类型'string',因为它不是委托类型 - Cannot convert lambda expression to type 'string' because it is not a delegate type 无法将lambda表达式转换为类型&#39;string&#39;,因为它不是具有NotifyOfPropertyChange的委托类型 - Cannot convert lambda expression to type 'string' because it is not a delegate type With NotifyOfPropertyChange
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM