In a WinForms ReactiveUI ViewModel I have a property with a property setter that can throw an ArgumentException:
public string Foo
{
get { return _foo; }
set
{
if (value == "ERR" ) throw new ArgumentException("simulate an error");
this.RaiseAndSetIfChanged(ref _foo, value);
Debug.WriteLine(string.Format("Set Foo to {0}", _foo));
}
}
private string _foo;
In View the property Foo is bind to a textbox uiFoo:
this.Bind(ViewModel, vm => vm.Foo, v => v.uiFoo.Text);
Binding works properly (as shown by the output of the setter’s Debug.WriteLine). But after typing “ERR” which throws ArgumentException the binding no longer works.
What solution do I have to bring back (or keep) binding in working state after the exceptions in setter ?