Hello,
I'm using version 15.1 for the XamNumericEditor editor.I want to limit the end user to enter a value between 1 and 400 in the editor.The only problem occurs when the user pastes a value out of range. The editor still accepts the value and displays the out of range value.Here's what I have for the editor:
<igEditors:XamNumericEditor Width="50" SpinButtonDisplayMode="Always" IsAlwaysInEditMode="True" AlwaysValidate="True" SpinIncrement="1" DataMode="Raw" Mask="{}{char:3:0-9}%" PromptChar="" InvalidValueBehavior="RevertValue" ValueType="{x:Type sys:Int64}" Value="{Binding ImageWidthTransform, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" > <igEditors:XamNumericEditor.ValueConstraint> <igEditors:ValueConstraint Nullable="False" MinInclusive="1" MaxInclusive="400" /> </igEditors:XamNumericEditor.ValueConstraint> </igEditors:XamNumericEditor>
I used the property InvalidValueBehavior and set it to "RevertValue" because I want to revert the value if an invalid/out of range value gets pasted into the editor.The value never gets reverted.I also tried to set the mask to "number:1-400" instead of the ValueConstraint, but still the same result.
Though the editor disables the up/down arrows if the value reached the max/min value. Also, typing the value will limit it to max value of 400. But pasting the value will not be limited.
Any ideas?
Thanks
Hello Corneliu,
Thank you for contacting us!
I have been looking into your question. Currently the validation of the value in the XamNumericEditor is done when the editor exits edit mode or loses focus.
One possible solution if to handle the ExecutingCommand as this event fires when the value is pasted. In the handler of the event you can make a check if the name of the command is 'Paste', then you can get the value from the Clipboard using the GetText method of that class.
After you get the value you can check if it is in the range of valid values. If it is not you can cancel the event.
Please do not hesitate to let me know if you have any further questions on this matter.
Since I set the property "AlwaysValidate" to "True" and I was losing focus after pasting the value, I believe the control should still revert to a previous valid value.I finally got it to work by updating the control's property "IsAlwaysInEditMode" to "false". That will revert the value to a previous valid value after I press enter or the control loses focus. I don't exactly understand why that fixes it but I'll take it. Though I think it's a bug if the value doesn't revert as all the properties were set properly.
Thanks for the idea to "exit the edit mode" in order to revert the value!