0

I bound a text property of a field on a sub-objet of an object. Do i have to instanciate this object to receive the data if the user enter a data ? Or will it be instanciate automatically ?

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();
}
draco951
  • 226
  • 3
  • 13

1 Answers1

0

Yes you have to instanciate it. MvvmCross does not create complex objects implicitly. It will not crash, but you will see an error/warning in the output/log/trace.

Sven-Michael Stübe
  • 14,560
  • 4
  • 52
  • 103
  • Any idea for the following question http://stackoverflow.com/questions/42728757/markerclick-works-but-infowindowclick-does-not-open-viewmodel – casillas Mar 13 '17 at 15:08