我有一个观点
public class TestView : MvxActionBarActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Create your application here
SetContentView(Resource.Layout.TestView);
var responsesList = this.FindViewById<MvxListView>(Resource.Id.listView);
var responsesAdapter = new TestViewAdapter(this, (IMvxAndroidBindingContext) BindingContext );
responsesList.Adapter = responsesAdapter;
var set = this.CreateBindingSet<TestView, TestViewModel>();
set.Bind(responsesAdapter).For(s => s.Responses).To(vm => vm.Responses);
set.Bind(responsesList).For(x => x.ItemsSource).To(vm => vm.Responses);
set.Bind(responsesList).For(x => x.ItemClick).To(vm => vm.ShowDetailEntry);
set.Apply();
}
}
由于某种原因,上面的代码说明绑定上下文的未知解决错误。我无法弄清楚为什么Xamaring MVVM Cross上有大量缺乏教程。我错过了什么:
var responsesAdapter = new TestViewAdapter(this, (IMvxAndroidBindingContext) BindingContext );
'curried' function 适配器代码:
public class TestViewAdapter : MvxAdapter
{
public TestAdapter(Context context, IMvxAndroidBindingContext bindingContext)
: base(context, bindingContext)
{
}
public List<TestResponse> Responses { get; set; }
protected override View GetBindableView(View convertView, object source, int templateId)
{
if (Session.CurrentArea == 2)
{
templateId = Resource.Layout.quickview_row;
}
return base.GetBindableView(convertView, source, templateId);
}
}