I have a TextBox
which has a binding for a non-nullable decimal value. This is my XAML code below. I need the UpdateSourceTrigger
and the ValidatesOnDataErrors=true
.
<TextBox
Text="{Binding Quantity, StringFormat=f2, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
/>
The problem is that on the TextBox
the values 0.00 is always displayed. When I start typing on the TextBox
the 0.00 is always there. To get the values after the decimal, the next arrow keys should be used. When a decimal point is typed then the TextBox
allows two decimal points but since the data annotations for the property is listed it shows an error and then we will have to hit the backspace button to clear the decimal zeros. How can I make the TextBox
to show an empty string when the value is zero and when I start typing, the TextBox
should accept the values that are typed in and not show the 0.00.