我有瑞士绑定的EditText(最后一行):
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:MvxBind="Visibility Visibility(WebServiceEditVisible); Text EditTextWebServiceAdress" />
如何使用Fluent绑定编写与Visibility插件和Text属性的绑定?
答案 0 :(得分:2)
与您实施的瑞士绑定相当的流利绑定将是:
资源文件:
<EditText
android:id="@+id/your_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
代码隐藏:
var myEditText = view.FindViewById<EditText>(Resource.Id.your_edit_text);
var bindingSet = this.CreateBindingSet<YourView, YourViewModel>();
bindingSet.Bind(yourEditText).For(c => c.Text).To(vm =>
vm.EditTextWebServiceAdress);
bindingSet.Bind(yourEditText).For(c => c.Visibility).To(vm =>
vm.WebServiceEditVisible).WithConversion(new MvxVisibilityValueConverter());
bindingSet.Apply();
此代码将包含片段的OnCreateView覆盖。如果您在某个活动中工作,它会进入OnCreate,您需要将view.FindViewById<EditText>(Resource.Id.your_edit_text);
更改为FindViewById<EditText>(Resource.Id.your_edit_text);
。