我不断收到以下错误消息:
MvxBind:Warning: 15.51 Unable to bind: source property source not found
Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyNamePropertyToken on null-object
找不到此问题的解决方案 - 3 小时后。
这就是 View 模型:
public class SettingsViewModel : MvxViewModel
{
public SettingsViewModel()
{
}
private bool testdata;
public bool Testdata
{
get { return testdata; }
set
{
testdata = value;
RaisePropertyChanged(() => Testdata);
//Debug.WriteLine("IN");
}
}
}
View :
[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 绑定(bind)到 Testdata 属性时发生错误。
感谢任何帮助!
最佳答案
这里警告的关键部分似乎是on null-object
默认情况下,MvvmCross View
在 ViewDidLoad()
期间找到它们的 ViewModel
- 因此解决您当前问题的方法可能是调用base.ViewDidLoad()
:
public override void ViewDidLoad()
{
base.ViewDidLoad();
// the rest of your Load code
}
关于ios - MonoTouch.Dialog 无法绑定(bind)源属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18588011/