android - MVVMCross: Binding Two Way doesn't update viewmodel -


I'm trying to tie a property into a custom control in a Xamarin.Android project.

  Public category MyControl: Relative layout {public supervision collection & lt; String & gt; MyProperty {Get; Set; }}  

When MyProperty is updated to the ViewModel side, it updates exactly in the MyProperty view. However, if I update Myopporte to the scene, then I can not do anything.

Binding:

  Public class MyControlMyPropertyTargetBinding: MvxAndroidTargetBinding {Private bool _subscribed; MyControl Protect MyControl ({Return (MyControl);}} Public MyControlMyPropertyTargetBinding (MyControl Target): Base (Target) {} Safe Override Zero SetValueImpl (Object Target, Object Value) {var myControl = (MyControl) Target; MyControl MyProperty = (Observable Collection & lt; String & gt;) Value;} Public Override Type Type {Receive {Return Type (Observeable Collection & lt; String & gt;);}} Public Override MvxBindingMode DefaultMode {get {return MvxBindingMode .TwoWay;}} Public Over Aid Zero Membership Receiver () {base.SubscribeToEvents (); Var myControl = MyControl; if (myControl == faucet} myControl.MyProperty == Faucet; MyControl.MyProperty.CollectionChanged + = MyPropertyOnCollectionChanged; _subscribed = true;} Private Zero MyPropertyOnCollectionChanged (Object Sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) {FireValueChanged (MyControl.MyProperty);} Safe Override Zero (Hair Disposing) is {base.Dispose (isisposing); If (disjoint) {var myControl = MyControl; If (myControl! = Null & amp; amp; myControl.MyProperty! = Null & amp; _subscribed) {myControl.MyProperty.CollectionChanged - = MyPropertyOnCollectionChanged; _subscribed = false; }}}}  

Setup.cs:

  Protected Override Zero FillTargetFactories (IMvxTargetBindingFactoryRegistry registry) {registry.RegisterCustomBindingFactory & lt ; MyControl & gt; ("MyProperty", MipProtti => New Microintroduction Targeting Badding (Mepropytti)); } Safe Override IList & lt; Assembly & gt; AndroidViewAssemblies {get {var assemblies = base.AndroidViewAssemblies; Assemblies.Add (typeof (myControl) .asembly); Return legislatures; }}  

Update: The same control binded on Windows Phone works perfectly in two ways.

Edit 1: I updated the target binding with the change in the archive but nothing is removed. Observeable collection is updated according to the program, not by user input.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -