Binding is so powerful in WPF. Supposed that we have a Number property (nullable int) and is bound to a textbox.
I realized when it throws an error, the property has the last correct value.
I mean these are the processes:
TEXTBOX: "" PROPERTY: null
TEXTBOX: "2" PROPERTY: 2
TEXTBOX: "2b" PROPERTY: 2 <-- here is the problem, should be null instead 2(by the error)
Is there a way which the binding set a null value when it produce an error?
Some persons told me I need to implement IDataErrorInfo, but I guess that interface is to validate business rules. So I wouldn't prefer user it.
UPDATE:
<TextBox Text="{Binding Number, UpdateSourceTrigger=PropertyChanged,
ValidatesOnExceptions=True, ValidatesOnDataErrors=True,
NotifyOnValidationError=True, TargetNullValue={x:Static sys:String.Empty}}"