<EditText androID:layout_wIDth="fill_parent" androID:layout_gravity="center" androID:textSize="16dp" androID:minWIDth="168dp" local:MvxBind="Text SelectedCode,UpdateSourceTrigger=LostFocus" />
但我找不到Wiki的正确语法
我知道这可能在框架内但无法找到参考.
想法?
TIA.
解决方法 绑定语法不提供UpdateSourceTrigger更改触发机制的唯一方法是:
>提供自定义绑定
>或提供自定义控件
我会去自定义绑定 – 类似于:
public class MvxEditTextFocusChangeTextSpecialTargetBinding : MvxAndroIDTargetBinding{ protected EditText EditText { get { return (EditText)Target; } } private bool _subscribed; public MvxEditTextFocusChangeTextSpecialTargetBinding(EditText vIEw) : base(vIEw) { } protected overrIDe voID SetValueImpl(object target,object value) { var editText = EditText; if (editText == null) return; value = value ?? string.Empty; editText.Text = value.ToString(); } public overrIDe MvxBindingMode DefaultMode { get { return MvxBindingMode.TwoWay; } } public overrIDe voID SubscribetoEvents() { var editText = EditText; if (editText == null) return; editText.FocusChange += HandleFocusChange; _subscribed = true; } private voID HandleFocusChange(object sender,VIEw.FocusChangeEventArgs e) { var editText = EditText; if (editText == null) return; if (!e.HasFocus) FireValueChanged(editText.Text); } public overrIDe Type targettype { get { return typeof(string); } } protected overrIDe voID dispose(bool isdisposing) { if (isdisposing) { var editText = EditText; if (editText != null && _subscribed) { editText.FocusChange -= HandleFocusChange; _subscribed = false; } } base.dispose(isdisposing); }}
注册使用:
registry.RegisterCustomBindingFactory<EditText>("FocusText",textVIEw => new MvxEditTextFocusChangeTextSpecialTargetBinding(textVIEw));
然后用作:
local:MvxBind="FocusText VMProperty"
有关自定义绑定的更多信息,请参阅N = 28教程 – http://slodge.blogspot.co.uk/2013/06/n28-custom-bindings-n1-days-of-mvvmcross.html
总结以上是内存溢出为你收集整理的数据绑定 – MvvmCross:更改MonoDroid上绑定的更新源触发器属性全部内容,希望文章能够帮你解决数据绑定 – MvvmCross:更改MonoDroid上绑定的更新源触发器属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)