MonoTouch.Dialog无法绑定源属性

时间:2013-09-03 08:56:52

标签: ios binding xamarin.ios mvvmcross monotouch.dialog

我一直在跟踪错误消息:

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

无法找到解决方案 - 现在已经3个小时了。

这是Viewmodel:

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 Property时发生错误。

任何帮助表示赞赏!

1 个答案:

答案 0 :(得分:1)

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

默认情况下,MvvmCross ViewViewModel期间找到他们的ViewDidLoad() - 因此解决当前问题的方法可能是致电base.ViewDidLoad()

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

    // the rest of your Load code
}