Clear btn in textbox breaks binding to binded text property
Describe the bug While using the textbox, i enabled ShowClearButton. When the clear btn is pressed, it clears the text in the view(Good) but the binded text property still retain it previous value and won't update on any further text changed. Seems like the binding to the ViewModel property is broken.
<hc:TextBox Margin="2,5" hc:InfoElement.ContentHeight="40" hc:InfoElement.Necessary="True" hc:InfoElement.Placeholder="Account Code" hc:InfoElement.Title="Account Code" CharacterCasing="Upper" FontWeight="Regular" ShowClearButton="True" Text="{Binding AccountCode, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" TextWrapping="Wrap" />
Link to video https://cloud.igeeksng.com/index.php/s/gBHmgR9fowKyKgb
I found this article online.
When you set the Text property in the code behind, you are changing the local value of the Text property. The binding in XAML also set local value for the Text property. Actually, the binindg is not disconnected, it is true that the binding value does not affects at that moment. Based on my experience, you could react the binding by invoking the UpdateTarget method on the BindingExpression class explicitly to update the binding value.
After some digging, i realize the binding expression after one click on the cancel btn returns null value.

Hello. I finding found a fix to the bug. In the source code of TextBox.

I changes ClearValue to SetCurrentValue
@ehinolakingsley a fix is pending https://github.com/HandyOrg/HandyControl/pull/135
@ghost1372 Awesome. One more thing.
I will love the highlighted part to be string == empty rather than checking for null value.
I believe when i pass in null value i don't want to see the data validation error but only on empty character.
Thanks