如何绑定'选择' MvvmCross中的UIButton的财产

时间:2017-07-31 14:03:17

标签: uibutton mvvmcross selected

我有一个奇怪的事情。在模拟器iOS 10.3上。以下代码工作正常。

    set.Bind(Circle1).For("Selected").To(vm => vm.PincodeCircles[0].Activated);

在我的iPad Pro 12.9上,出现以下错误:

[0:] MvxBind:警告:2.68无法为PincodeCircles [0]选择的绑定创建目标绑定。激活

我已经尝试了以下内容:

    set.Bind(Circle1).For(button => button.Selected).To(vm => vm.PincodeCircles[0].Activated);

并给出了同样的错误:

[0:] MvxBind:警告:4.27无法为PincodeCircles [0]选择的绑定创建目标绑定.Activated

在viewmodel上激活的定义如下:

    public bool Activated
    {
        get { return this._activated; }
        set { this.SetProperty(ref this._activated, value); }
    }

Cirle1按钮的类型为UICircleButton。这是班级:

using CoreGraphics;
using Foundation;
using System;
using UIKit;

namespace NN.Plugin.Utils.iOS
{
    public partial class UICircleButton : UIButton
    {
        public UICircleButton(IntPtr handle) : base(handle)
        {
            Layer.BorderColor = UIColor.Black.CGColor;
            Layer.BorderWidth = 2;
        }

        public nfloat BorderWidth
        {   get
            {
                return Layer.BorderWidth;
            }
            set
            {
                Layer.BorderWidth = value;
            }
        }

        public CGColor BorderColor
        {
            get
            {
                return Layer.BorderColor;
            }
            set
            {
                Layer.BorderColor = value;
            }
        }

        public nfloat PointSize
        {
            get => Font.PointSize;
            set => Font = Font.WithSize(value);
        }

        public override CGRect ContentRectForBounds(CGRect rect)
        {
            var newRect = base.ContentRectForBounds(rect);

            Layer.CornerRadius = newRect.Width / 2;

            return newRect;
        }
    }
}

0 个答案:

没有答案
相关问题