Mvvmcross (iOS) Binding UIViewController Header

Is it possible to associate the title of a UIViewController element with the String property of the ViewModel? It does not seem to be updating. As a side issue, if you did not set the title to something before binding, then the Mvvmcross code crashes during installation. A call is made. ().

UIViewController does not have .xib, I'm not sure if this part of the problem.

public override void ViewDidLoad() { base.ViewDidLoad(); var set = this.CreateBindingSet<HomeView, HomeViewModel>(); set.Bind(Title).To(vm => vm.ProjectName); set.Apply(); } 

Here's the stack trace

2014-02-05 17: 09: 35.740 TerraFlex [9145: 907] 05/05/2014 17: 09: 35: 7403: 1: [Info] HomeView uploaded Topic started: # 12 2014-02-05 17: 09: 36.219 TerraFlex [9145: 907] 02-05-2014 17: 09: 36: 2190: 1: [Fatal] A critical error occurred and the application was closed 2014-02-05 17: 09: 36.250 TerraFlex [9145: 907] 02 -05-2014 17: 09: 36: 2497: 1: [Fatal] Date: 02/05/2014 5:09:36 PM, [Exception] fatal Message: The reference to the object is not installed in the object instance Stack: in Cirrious.MvvmCross.Binding.Bindings.Target.Construction.MvxTargetBindingFactoryRegistry.TryCreateSpecificFactoryBinding (System.Object, System.String targetName, IMvxTargetBinding & binding) [0x00001] in c: \ Projects \ Misc \ Misc \ Misc \ Misc MVIR \ Misc \ Misc \ Misc \ MVisc \ Misc \ MvvmCross.Binding \ Handcuffs \ Target \ Building \ MvxTargetBindingFactoryRegistry.cs: 69 in Cirrious.MvvmCross.Binding.Bindings.Target.Construction.MvxTargetBindingFactoryRegistry.CreateBinding (System.Object, System.Stringx1 project] [0] \ Misc \ MVVMCROSS \ Cirrious \ Cirrious.MvvmCrossBinding \ Bindings \ Target \ Build \ MvxTargetBindingFactoryRegistry.cs: 22 in Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.CreateTargetBinding (target object System.Object \) Misc \ MVVMCROSS \ Cirrious \ Cirrious.MvvmCrossBinding \ Bindings \ MvxFullBinding.cs: 135 in Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding..ctor (Cirrious.MvvmCross.Binding.MvxBindingRequest bindingRe00est [0] 0) \ MVVMCROSS \ Cirrious \ Cirrious.MvvmCrossBinding \ Bindings \ MvxFullBinding.cs: 60 in Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (Cirrious.MvvmCross.Binding.MvxBindingReq uest bindingRequest) [0x00001] in c: \ Projects \ Misc \ MVVMCROSS \ Cirrious \ Cirrious.MvvmCrossBinding \ Binders \ MvxFromTextBinder.cs: 55 in Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder + <> c_m_vis_m_vis_m_vis_mis Binding.Bindings.MvxBindingDescription description) [0x00000] in c: \ Projects \ Misc \ MVVMCROSS \ Cirrious \ Cirrious.MvvmCross.Binding \ Binders \ MvxFromTextBinder.cs: 37 in System.Linq.Enumerable + c__Iterator10 2[Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription,Cirrious.MvvmCross.Binding.Bindings.IMvxUpdateableBinding].MoveNext () [0x00000] in <filename unknown>:0 at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBindings (IMvxBindingContextOwner view, IEnumerable .Object clearKey) [0x00028] in c: \ Projects \ Misc \ MVVMCROSS \ Cirrious \ Cirrious.MvvmCross.Binding \ BindingContext \ MvxBindingContextOwnerExtensions.cs: 69 in Cirrious.MvvmCross.Binding.BindingContext.Mvxinding s. 1 bindingDescriptions, System.Object clearKey) [0x00019] in c:\Projects\Misc\MVVMCROSS\Cirrious\Cirrious.MvvmCross.Binding\BindingContext\MvxBindingContextOwnerExtensions.cs:90 at Cirrious.MvvmCross.Binding.BindingContext.MvxBindingContextOwnerExtensions.AddBinding (IMvxBindingContextOwner view, System.Object target, Cirrious.MvvmCross.Binding.Bindings.MvxBindingDescription bindingDescription, System.Object clearKey) [0x0000e] in c:\Projects\Misc\MVVMCROSS\Cirrious\Cirrious.MvvmCross.Binding\BindingContext\MvxBindingContextOwnerExtensions.cs:83 at Cirrious.MvvmCross.Binding.BindingContext.MvxBaseFluentBindingDescription 1 [System.String] .Apply () [0x00000] in. `2 [Trimble.TFM.FieldApp.HomeView, Trimble.TFM.FieldApp.Common.HomeViewModel] .Apply () [0x00000] at: 0

Thanks, John

+7
mvvmcross
source share
1 answer

Free binding uses code such as:

  set .Bind(<target object for bind>) .For(<property on target object>) // leave this out to use the "default binding property for the target object" .To(<property/expression on source object>) .WithConversion(<converter>, <converter parameter>) // optional .OneWay() // optional - also: OneWayToSource(), TwoWay() or OneTime() .FallbackValue(<value to use for UnsetValue>(); // optional 

You can learn more about this at:


Your binding:

 set.Bind(Title).To(vm => vm.ProjectName); 

So, you become attached:

I assume you wanted:

 set.Bind(this).For(v => v.Title).To(vm => vm.ProjectName); 

I think you can also do this as:

 set.Bind().For(v => v.Title).To(vm => vm.ProjectName); 

With that said, the Mvx stack should not have barfed if it had a target and a null property - it was not used - so I will add this as a problem to examine and add a regression test for why TryCreateSpecificFactoryBinding cannot handle null .

+13
source share

All Articles