MvvmCross:iOS 设备上的绑定警告

MvvmCross: Binding warning on iOS device

我已经按照斯图尔特在 Post 中所说的那样创建了我的绑定:MvvmCross - How to bind UIView.Layer.AnyProperty (Xamarin.iOS) to a property on a viewmodel?

这在模拟器上运行良好,但在 iOS 设备上运行不佳。我已经添加了 LinkerPleaseInclude.cs 但这没有任何改变。

绑定到 BorderWidth 完美运行,绑定到 BorderColor 显示警告。

LinkerPleaseInclude.cs:

public class LinkerPleaseInclude
{
    public void Include(UIButton uiButton)
    {
        uiButton.TouchUpInside += (s, e) =>
                                  uiButton.SetTitle(uiButton.Title(UIControlState.Normal), UIControlState.Normal);
    }

    public void Include(UIBarButtonItem barButton)
    {
        barButton.Clicked += (s, e) =>
                             barButton.Title = barButton.Title + "";
    }

    public void Include(UITextField textField)
    {
        textField.Text = textField.Text + "";
        textField.EditingChanged += (sender, args) => { textField.Text = ""; };
    }

    public void Include(UITextView textView)
    {
        textView.Text = textView.Text + "";
        textView.Changed += (sender, args) => { textView.Text = ""; };
    }

    public void Include(UILabel label)
    {
        label.Text = label.Text + "";
    }

    public void Include(UIImageView imageView)
    {
        imageView.Image = new UIImage();
    }

    public void Include(UIDatePicker date)
    {
        date.Date = date.Date.AddSeconds(1);
        date.ValueChanged += (sender, args) => { date.Date = DateTime.MaxValue.ToNSDate(); };
    }

    public void Include(UISlider slider)
    {
        slider.Value = slider.Value + 1;
        slider.ValueChanged += (sender, args) => { slider.Value = 1; };
    }

    public void Include(UISwitch sw)
    {
        sw.On = !sw.On;
        sw.ValueChanged += (sender, args) => { sw.On = false; };
    }

    public void Include(INotifyCollectionChanged changed)
    {
        changed.CollectionChanged += (s,e) => { var test = string.Format("{0}{1}{2}{3}{4}", e.Action,e.NewItems, e.NewStartingIndex, e.OldItems, e.OldStartingIndex); } ;
    }
}

我的绑定代码:

bindingSet.Bind(this.MyUITextField.Layer)
              .For(x => x.BorderColor)
              .To(x => x.MyViewModelProperty.IsValid)
              .WithConversion("ValidationStyleBorderColor");
bindingSet.Bind(this.MyUITextField.Layer)
              .For(x => x.BorderWidth)
              .To(x => x.MyViewModelProperty.IsValid)
              .WithConversion("ValidationStyleBorderWidth");
bindingSet.Apply();

我的转换器:

public class ValidationStyleBorderColorValueConverter : MvxValueConverter<bool, CGColor>
{
    protected override CGColor Convert(bool value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return value == true ? Themes.Default.HighlightColor.CGColor : Themes.Default.ErrorColor.CGColor;
    }
}

和警告:MvxBind:警告:22,91 无法为 MyViewModelProperty.IsValid

的绑定 BorderColor 创建目标绑定

我做错了什么?

正如 Stuart 所说,包括 LinkerPleaseInclude 中的 Border 属性成功了。