Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
XamNumericEditor allows pasting out of range values
posted

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

Parents
  • 22015
    posted

    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.

Reply Children