var s = Observable.FromEventPattern(txtValue1, "Leave");
this.Bind(ViewModel, vm => vm.Value2, f => f.txtValue1.Text, s);
Being a text box, I can enter anything. I could restrict key press events so that only digits, period and +/- are enterable but that doesn't stop a user entering an invalid integer format such as 1+-2.
Ideally, if there's a binding conversion failure I want to reset the textbox's text property to either the previous value or a fallback value.
Given conversion failures are silently swallowed by the framework I'm not sure what the best way to expose them is. The converters themselves don't have the context about how they were called so there's nothing obvious I can send back to the view to tell it to refresh/reset the display.
Maybe a BindError object , like UserError, could work and we call BindError.Throw from within the PropertyBinderImplementation class whenever a TryConvert method fails. But even then I'm not really sure how to get the textbox to refresh consistently.
For example, I tried adding a button to the UI (just as a test) that set the ViewModel value to 0. Unsurprisingly the text box refreshed to 0 as expected when the VM.Value1 property was non-zero. If it was already 0 nothing happens as the Value1 property value hasn't actually changed and no observable change occurs.
Any thoughts?