ghost1372 / HandyControls

Contains some simple and commonly used WPF controls based on HandyControl
https://ghost1372.github.io/
MIT License
1.1k stars 104 forks source link

When setting the property ShowClearButton="True" for the control hc:TextBox, Click on the Clear button throws an exception. #131

Closed steveyan00 closed 2 years ago

steveyan00 commented 2 years ago

Describe the bug When setting the property ShowClearButton="True" for the control hc:TextBox, Click on the Clear button throws an exception.

To Reproduce Steps to reproduce the behavior:

  1. <hc:TextBox ShowClearButton="True" Text={Binding Variable} />
  2. Click the Clear button and enter something.
  3. 7 : ConvertBack cannot convert value '' (type 'String'). BindingExpression:Path=AIntVariable; DataItem='MainViewModel' (HashCode=xxxxxxxx); target element is 'TextBox' (Name=''); target property is 'Text' (type 'String') FormatException:'System.FormatException: Input string was not in a correct format.

Expected behavior Add a judgment for the empty string. The value can be set to 0 if it is empty.

Screenshots image image image image

Environment (please complete the following information):

ps: The above is translated from DeepL.

ghost1372 commented 2 years ago

https://github.com/ghost1372/HandyControls/issues/48