HandyControl
HandyControl copied to clipboard
当设置hc:TextBox的属性ShowClearButton=true时,某些情况下点击清除按钮,会引起无法消除的错误异常.
Describe the bug
当设置hc:TextBox的属性ShowClearButton=true,Text Binding变量类型为int等不可为null的类型的情况时,点击清除按钮会引起无法消除的错误异常.
Steps to reproduce the bug
- MainViewModel中public int IntVar;
- <hc:TextBox ShowClearButton="True" Text={Binding Variable} />
- 点击Clear按钮.
- 文本框变红,且不可消除. 错误信息:ConvertBack cannot convert value '' (type 'String'). BindingExpression:Path=IntVar; 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.
Expected behavior
点击Clear时,可以变成binding类型的默认值.
Screenshots
NuGet package version
HandyControls (Custom version) 3.3.11
IDE
Visual Studio 2022
Framework type
.Net 6.0
Windows version
May 2021 Update (19043)
Additional context
No response