Search code examples
xamarinmvvmcross

MVVMCross binding to badgevalue


I am trying to bind to the badgevalue of a TabBarItem like this:

var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(ViewControllers[0].TabBarItem.BadgeValue).To(vm => vm.MyNumber);
set.Apply();

but I get the following error:

MvxBind: Error:   6.30 Empty binding target passed to MvxTargetBindingFactoryRegistry

However if I set the value directly like this the badge appears:

ViewControllers[0].TabBarItem.BadgeValue = ((MyViewModel)ViewModel).MyNumber;

Why is the binding not working? Thanks!


Solution

  • This doesn't work because you need to set up your own binding extensions if what you are trying to bind to doesn't exist as a valid binding target already.

    Look here where Stuart answered a similar question for Android.