-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
OneWayBind throws an error when the value is null
The vm has a reactiveProperty called appointment which itself has a reactive DateTime property Canceled
this.OneWayBind(ViewModel, vm => vm.Appointment.Canceled, v => v.CanceledDateTime.Text, dt => dt?.ToString("G"));
compiles but at runtime when vm.Appointment.Canceled is null throws System.ArgumentNullException
message: Value cannot be null.
Parameter name: paramValue
It looks like BindToDirect,(PropertyBinderImplementation.cs line 322) is looking for a setter, but it is a oneWayBind so there is no setter
Changing to Bind gets around the problem:
this.Bind(ViewModel, vm => vm.Appointment.Canceled, v => v.CanceledDateTime.Text, dt => dt?.ToString("G"), s=> s == "" ? (DateTime?) null : DateTime.Parse(s));
Environment
- OS: Windows 10, WPF
- Version 11.5.6
This behavior works as expected, i. e. The bound value can be null when using OneWayBind in version 11.4.17