1

我不断收到以下错误消息:

MvxBind:Warning: 15.51 Unable to bind: source property source not found 
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyNamePropertyToken on null-object

找不到解决方案 - 从现在开始 3 小时。

这就是视图模型:

public class SettingsViewModel : MvxViewModel
{
    public SettingsViewModel()
    {

    }

    private bool testdata;
    public bool Testdata
    {
        get { return testdata; }
        set 
        {
            testdata = value; 
            RaisePropertyChanged(() => Testdata);
            //Debug.WriteLine("IN");
        }
    }
}

风景:

[Register("SettingsView")]
public class SettingsView : MvxDialogViewController
{
    public SettingsView()
        : base(pushing: true)
    {

    }

    public override void ViewDidLoad()
    {
        var bindings = this.CreateInlineBindingTarget<SettingsViewModel>();
        Root = new RootElement("Settings"){
             new Section("General")
             {
                 new BooleanElement("Testdata ON/OFF", true).Bind(bindings, t => t.Testdata)
             }
         };
    }
}

尝试将 de booleanelement 绑定到 Testdata 属性时发生错误。

任何帮助表示赞赏!

4

1 回答 1

1

这里警告的关键部分似乎是on null-object

默认情况下, MvvmCross s在此期间View找到它们的 s - 所以解决您当前问题的方法可能是调用:ViewModelViewDidLoad()base.ViewDidLoad()

public override void ViewDidLoad()
{
    base.ViewDidLoad();

    // the rest of your Load code
}
于 2013-09-03T13:44:22.510 回答