I have below code implemented, which shows the formatted value.
my query here is, the control does not update Property, when user hits "Delete" / "Backspace" Keyboard button. What is the possible workaround here?
Note: I don't want to use the "_" or " " mask here
I came across "IsValueChangingFromInternal " property of InputBase, but didn't get enough documentation or samples around it to figure out, if i could use that.
Can you please help me resolve the issue?
Thanks in Advance :)
5 Answers, 1 is accepted
Could you please give us some test cases we can investigate ? For example the Value is 12345.67 the cursor is between 2 and 3 and you press backspace or delete. Let us know in these scenarios what is the exact cursor position and the value you expect. Also, we need the style setters from your "RadMaskedCurrencyInputStyle". Thank you in advance for your cooperation.
Additionaly, we believe eveything could be achieved with no-mask and formatstring and extension properties. Could you please elaborate more on the reasons you cannot use no-mask feature ?
Essentially, i am looking for a use case, where user selects the entire Text on the control, through Tab in to the control or similar, and Hits Keyboard key Delete / Backspace, provided the Text has 0.00 or 0 in it (which is a default value). The background property's Setter is not getting triggered.
Control Template Triggers:
Please let me know, if anymore information required.
Thank you for the additional code. I added the style setters and used them. When the MaskedInput gets focused, SelectAll is performed and if you press delete or backspace - the Value is getting Null and the control becomes blank / empty which is expected. As I managed to understand you need to revert to 0.00 or 0 when you press the backspace or delete key in this scenarios. If so, you can try setting:
Let me know if this is what you needed.
Setting above property, does put the default value back in the control text. In my scenario, i want to set some other property in view model, if user Deletes the value from control Text, even after user tries to Delete 0 (To Enable some flag, which represents, Change occurred on View).
The solution above is helpful, but doesn't completely resolve my requirement.
Generally if you need to edit the value while you type (we can call this coerce), you can use the PreviewValueChanged event in code behind or the ViewModels' property which is bound to the Value property pf the MasledInput. Could you please elaborate more on the difficulties you experience in implementing such approach ? This way we would be better able to advice you.