我正在用MvvmCross编写一个简单的Xamarin应用程序。我只是想做一些绑定,但是编译器给了我这个错误
以下方法或属性之间的调用不明确:“ MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.CreateBindingSet(TTarget)”和 'MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.CreateBindingSet(TTarget)**。在
处引发此错误var set = this.CreateBindingSet<LoginViewController, LoginViewModel>();
我在Xamarin.iOS项目中添加了MvvmCross,MvvmCross.Binding,MvvmCross.Platform和MvvmCross.Core。
请帮助摆脱该错误。下面是我的ViewController的代码:
using Kinettix.Core.ViewModels;
using MvvmCross.Binding.BindingContext;
using MvvmCross.Platforms.Ios.Views;
using UIKit;
namespace Kinettix.iOS.Views
{
public partial class LoginViewController : MvxViewController<LoginViewModel>
{
public LoginViewController() : base("LoginViewController", null)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
this.NavigationController.NavigationBarHidden = true;
var set = this.CreateBindingSet<LoginViewController, LoginViewModel>();
set.Apply();
tfUsername.ShouldReturn+= (sender) =>
{
sender.ResignFirstResponder();
return false;
};
tfPassword.ShouldReturn += (sender) =>
{
sender.ResignFirstResponder();
return false;
};
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
}
}
答案 0 :(得分:1)
好的。我找到了我问题的答案。我的iOS项目中有MvvmCross.Core,MvvmCross.Platform,MvvmCross.binding和MvvmCross。它抱怨在MvvmCross和MvvmCross.Binding之间对CreateBindingSet的模棱两可的调用。我删除了所有软件包,仅安装了MvvmCross。这样,它使用MvvmCross调用了CreateBindingSet并成功运行。 :)