Databinding Decimal Values

Editors for WPF Forum

Posted 13 years ago by Billy Jacobs
I have several places in my application where I bind decimals to textbox controls. I have UpdateSourceTrigger=PropertyChanged so that my buttons attached to commands enable when a valid value is entered so the user does not have to click out of the textbox to enable the save button.

Problem 1: Lets say you have the value 24.05 in the text. Now place the cursor between the 4 and the decimal place holder. Backspace 2 times and type in the number 8. Instead of 8.05 you get 80.05. Our users are used to being able to type without looking and expect what they type to be correct.

Problem 2: Type in the value .234. Instead of .234 you get 0.342.

I know I could solve the problem by changing UpdateSourceTrigger=PropertyChanged to UpdateSourceTrigger=LostFocus but this will cause the user to have to tab out of the control or click inside of another control to enable the save button which defeats the purpose of Commanding.

Do you have a control I can use to fix this or know of a workaround for this?

[Modified at 03/31/2011 12:03 PM]

Comments (1)

Posted 13 years ago by Billy Jacobs
StringFormat=\{0:#.##\} did the trick.
The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.