xamarin.android - MvvmCross: change update source trigger property of binding on MonoDroid -


i change default binding trigger propertychanged lostfocus on droid edittext view:

 <edittext                 android:layout_width="fill_parent"                 android:layout_gravity="center"                 android:textsize="16dp"                 android:minwidth="168dp"                 local:mvxbind="text selectedcode, updatesourcetrigger=lostfocus" /> 

but cannot find correct syntax wiki

i know possible within framework cannot find reference.

ideas?

tia.

the binding syntax doesn't provide updatesourcetrigger

the ways change triggering mechanism are:

  • to provide custom binding
  • or provide custom control

i'd go custom binding - like:

public class mvxedittextfocuschangetextspecialtargetbinding     : mvxandroidtargetbinding {     protected edittext edittext     {         { 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     {         { 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     {         { 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);     } } 

registered using:

registry.registercustombindingfactory<edittext>("focustext",                                                         textview => new mvxedittextfocuschangetextspecialtargetbinding(textview)); 

then used as:

 local:mvxbind="focustext vmproperty" 

for more on custom bindings, see n=28 tutorial - http://slodge.blogspot.co.uk/2013/06/n28-custom-bindings-n1-days-of-mvvmcross.html


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -