我在一个对象的子对象上绑定了一个字段的text属性。如果用户输入数据,是否必须将此对象设置为接收数据?或者它会自动生成吗?
public class BluetoothLeDevice
{
public User User { get; set; }
}
public class User
{
public string Lastname { get; set; }
}
public class MyViewModel : MvxViewModel
{
public BluetoothLeDevice Device { get; set; } = new BluetoothLeDevice();
}
private void CreateBinding(View view)
{
TextView tv_LastName = view.FindViewById<TextView>(Resource.Id.pair_stepper_user_lastname);
var set = this.CreateBindingSet<MyView, MyViewModel>();
set.Bind(tv_LastName).For(v => v.Text).To(vm => vm.Device.User.Lastname);
set.Apply();
}
答案 0 :(得分:0)
是的,你必须实现它。 MvvmCross不会隐式创建复杂对象。它不会崩溃,但您会在输出/日志/跟踪中看到错误/警告。