Binding to Text property ios-unified not working

2019-06-05 17:50发布

问题:

I updated my xamarin ios-project to the unified API (64 Bit support). Everything worked as expected. The project builds and works.

But I detected one problem. The binding to UILabel.Text properties won't work anymore. All other bindings are still working (to a UIButton.Hidden property for example). Here is my code:

// Create bindings
var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(labelitem)      // not working
    .For(t => t.Text)
    .To(v => v.MyStringValue);
set.Bind(buttonitem)     // working
    .For(b => b.Hidden)
    .To(v => v.MyboolValue)
    .WithConversion(new InverseBoolValueConverter());
set.Apply();

I'm using MvvmCross for the bindings. Bevore the unified-update everything worked fine.

First I tried to change the Linker-Option to "don't link". Same problem.

Can anyone explain me, what's happen? Thanks

Edit

I found a info in the output while debugging my project:

Weak Target is null in MvxUILabelTextTargetBinding - skipping set

回答1:

There are some issues that some people are seeing, others are not, with the new GC in the latest Xamarin "stable" releases (maybe differences between VS and XS - it's not clear...). You can read about these on https://github.com/MvvmCross/MvvmCross/issues/902 (with some background on Migrating to Unified API and new reference counting)

There's an attempt to address these in http://slodge.blogspot.co.uk/2015/02/351-alpha-release.html - please do try the alpha packages to see if they help.

If not, then the only accepted workaround right now is to promote your UILabel to a private variable in your View.