【发布时间】:2017-07-23 15:34:20
【问题描述】:
我在对象的子对象上绑定了字段的文本属性。如果用户输入数据,我是否必须实例化此对象才能接收数据?还是会自动实例化?
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();
}
【问题讨论】:
标签: android ios xamarin binding mvvmcross