strange Problem with WPF Textbox stringformat - Cursor moves back
- by Emad
I am using WPF 4.0 TextBox and binding. I am using StringFormat to format the number as currency. the XAML looks like this:
<TextBox Text="{Binding Path=ValueProperty, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, StringFormat={}{0:C}, UpdateSourceTrigger=PropertyChanged}">
</TextBox>
Everything seems to work correctly except for a strange behavior:
When for example a user types in 12: right after typing 1, the value in the textbox becomes $1.00 and the weird thing is the the cursor is moved to be between the $ and the 1.
So when a user simply types in 12, the result becomes $21.00.
How can I fix this strange behavior?