简体   繁体   中英

MVVMCross binding property works fine in iOS simulator but fails on device

I'm observing really strange behaviour. I have bound a UIProgressView located inside a custom cell view to a float property of my view model. To make clear here is my view model in core layer:

public class DownloadCellViewModel: MvxViewModel
{
    float _Progress;
    public float Progress {
        get{
            return _Progress;
        }
        set{
            _Progress = value;
            this.RaisePropertyChanged (() => this.Progress);
        }
    }
}

and here is my cell view binding code in UI front-end layer:

public DownloadCell (IntPtr handle) : base (handle)
    {   
        this.DelayBind(() => {
            var set = this.CreateBindingSet<DownloadCell, DownloadCellViewModel> ();

            set.Bind(ProgressDownload).For(p=>p.Progress).To(item=> item.Progress);

        set.Apply();
        });
    }

Please note, ProgressDownload is a UIProgressView which I put it on xib file. Now the problem is when I run this code it works as expected in simulator but on device I get following error:

MvxBind:Warning:104,99 Failed to create target binding for binding Progress for Progress

Any ideas?

I believe the linker optimisation is causing the problem Add the following to the LinkerPleaseInclude.cs file

public class LinkerIncludePlease
{
        public void Include(MvxTableViewCell vc)
        {
            vc.BackgroundColor = UIColor.Blue;
        }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM